diff --git a/bats_ai/core/views/guanometadata.py b/bats_ai/core/views/guanometadata.py index add1859..23c15bd 100644 --- a/bats_ai/core/views/guanometadata.py +++ b/bats_ai/core/views/guanometadata.py @@ -50,16 +50,16 @@ def default_data( nabat_fields['nabat_longitude'] = str(float(nabat_fields['nabat_longitude']) * -1) # Extract additional fields with conditionals additional_fields = { - 'nabat_activation_start_time': parse_datetime( - gfile.get('NABat|Activation start time', None) - ) - if 'NABat|Activation start time' in gfile - else None, - 'nabat_activation_end_time': parse_datetime( - gfile.get('NABat|Activation end time', None) - ) - if 'NABat|Activation end time' in gfile - else None, + 'nabat_activation_start_time': ( + parse_datetime(gfile.get('NABat|Activation start time', None)) + if 'NABat|Activation start time' in gfile + else None + ), + 'nabat_activation_end_time': ( + parse_datetime(gfile.get('NABat|Activation end time', None)) + if 'NABat|Activation end time' in gfile + else None + ), 'nabat_software_type': gfile.get('NABat|Software type', None), 'nabat_species_list': gfile.get('NABat|Species List', '').split(','), 'nabat_comments': gfile.get('NABat|Comments', None), diff --git a/bats_ai/core/views/recording.py b/bats_ai/core/views/recording.py index e7c892c..7699cc8 100644 --- a/bats_ai/core/views/recording.py +++ b/bats_ai/core/views/recording.py @@ -278,6 +278,8 @@ def get_spectrogram(request: HttpRequest, id: int): with colormap(None): spectrogram = recording.spectrogram + compressed = recording.compressed_spectrogram + spectro_data = { 'url': spectrogram.image_url, 'spectroInfo': { @@ -290,6 +292,12 @@ def get_spectrogram(request: HttpRequest, id: int): 'high_freq': spectrogram.frequency_max, }, } + if compressed: + spectro_data['compressed'] = { + 'start_times': compressed.starts, + 'end_times': compressed.stops, + } + # Get distinct other users who have made annotations on the recording if recording.owner == request.user: other_users_qs = ( @@ -579,7 +587,7 @@ def patch_annotation( annotation_instance.save() # Clear existing species associations - if species_ids: + if species_ids is not None: annotation_instance.species.clear() # Add species to the annotation based on the provided species_ids for species_id in species_ids: diff --git a/client/src/api/api.ts b/client/src/api/api.ts index fea6f67..bb9f824 100644 --- a/client/src/api/api.ts +++ b/client/src/api/api.ts @@ -113,6 +113,10 @@ export interface Spectrogram { annotations?: SpectrogramAnnotation[]; temporal?: SpectrogramTemporalAnnotation[]; spectroInfo?: SpectroInfo; + compressed?: { + start_times: number[]; + end_times: number[]; + } currentUser?: string; otherUsers?: UserInfo[]; diff --git a/client/src/components/SpectrogramViewer.vue b/client/src/components/SpectrogramViewer.vue index 9b2f729..a9e62dc 100644 --- a/client/src/components/SpectrogramViewer.vue +++ b/client/src/components/SpectrogramViewer.vue @@ -1,5 +1,5 @@