-
-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Summary
During V2 schema migration, ResolveBatch in labels/resolver.go currently forces all labels to use speciesLabelTypeID. However, BirdNET can produce non-species labels that should be properly categorized.
Current State (PR #1912)
The V2 normalized schema implementation currently:
- Initializes all labels as "species" type - This is a deliberate simplification for the initial implementation
- Seeds lookup tables during schema initialization -
label_types(species, noise, environment, device) andtaxonomic_classes(Aves, Chiroptera) are seeded inmanager.go - Self-initializes lookup IDs - Both
v2only.Datastoreand migrationWorkerautomatically look up required IDs from the database
Problem
The ParseRawLabel function in labels/parser.go can identify labels as different types:
species- bird speciesnoise- background noiseenvironment- environmental soundsdevice- device-related sounds
Currently, all labels are saved with label_type_id pointing to "species" regardless of what ParseRawLabel identifies.
Proposed Solution
Add manual mapping for known non-species classes so we can populate the label_type_id correctly during migration:
- Create a mapping table or constants for known non-species BirdNET outputs
- Update
ResolveBatchto use the parsed label type when creating labels - Ensure
BatchGetOrCreatecan handle mixed label types or group by label type
Files Affected
internal/datastore/v2/labels/resolver.go-ResolveBatchfunctioninternal/datastore/v2/labels/parser.go-ParseRawLabelfunctioninternal/datastore/v2/repository/label_impl.go-BatchGetOrCreatefunction
Static Maps Already in Place
The following are already defined in internal/datastore/v2/entities/:
Label Types (label_type.go):
func DefaultLabelTypes() []LabelType {
return []LabelType{
{Name: "species"},
{Name: "noise"},
{Name: "environment"},
{Name: "device"},
}
}Taxonomic Classes (taxonomic_class.go):
func DefaultTaxonomicClasses() []TaxonomicClass {
return []TaxonomicClass{
{Name: "Aves"}, // Birds
{Name: "Chiroptera"}, // Bats
}
}Context
Found during code review of feature/v2-normalized-schema branch (PR #1912).