Conversation
…into batbot-integration
Co-authored-by: Michael Nagler <mike.nagler@kitware.com>
naglepuff
left a comment
There was a problem hiding this comment.
I'm not sure if anything needs to change in particular, but I had some questions.
| if not details: # Ensure we return a consistent schema even if no details exist | ||
| return {'id': None, 'user_id': user_id, 'reference_materials': ''} |
There was a problem hiding this comment.
Was there an issue that this is helping to solve? I thought that the front end knew what to do if this endpoint 404'd. I wasn't expecting to see any changes to vetting details stuff in this PR
There was a problem hiding this comment.
I'll revert it. This is a hard one because we are using vetting/user/{user.id} where there should only be a single value per user, unlike anotherexample comment/{id} where there it is the intention of it to exist or not based on the Id.
Like if you had /vetting/user and it used the request authentication to determine the user_id I wouldn't want it to 404 if no value is set, it would just be an empty value indicating it hasn't been set yet. I viewed it not as a possible collection of data and more as
bats_ai/core/views/recording.py
Outdated
| items.append( | ||
| { | ||
| 'id': rec.id, | ||
| 'name': rec.name, | ||
| 'audio_file': str(rec.audio_file), | ||
| 'owner_id': rec.owner_id, | ||
| 'recorded_date': rec.recorded_date, | ||
| 'recorded_time': rec.recorded_time, | ||
| 'equipment': rec.equipment, | ||
| 'comments': rec.comments, | ||
| 'recording_location': location, | ||
| 'grts_cell_id': rec.grts_cell_id, | ||
| 'grts_cell': rec.grts_cell, | ||
| 'public': rec.public, | ||
| 'created': rec.created, | ||
| 'modified': rec.modified, | ||
| 'software': rec.software, | ||
| 'detector': rec.detector, | ||
| 'species_list': rec.species_list, | ||
| 'site_name': rec.site_name, | ||
| 'unusual_occurrences': rec.unusual_occurrences, | ||
| 'tags_text': getattr(rec, 'tags_text', None), | ||
| 'owner_username': rec.owner.username, | ||
| 'audio_file_presigned_url': default_storage.url(rec.audio_file.name), | ||
| 'hasSpectrogram': rec.has_spectrogram_attr, | ||
| 'userAnnotations': annotation_counts.get(rec.id, 0), | ||
| 'userMadeAnnotations': rec.id in user_has_annotations_ids, | ||
| 'fileAnnotations': [ | ||
| RecordingAnnotationSchema.from_orm(fa).dict() | ||
| for fa in rec.recordingannotation_set.all() | ||
| ], | ||
| } |
There was a problem hiding this comment.
Is there a schema class we can use here instead of appending this dictionary?
There was a problem hiding this comment.
I created a Schema, while doing this I also updated a possible failure condition when using ArrayAgg for the tag text values.
| for tag in tag_list: | ||
| queryset = queryset.filter(tags__text=tag) | ||
| if tag_list: | ||
| queryset = queryset.distinct() |
There was a problem hiding this comment.
Is tag_list ever None in this block?
There was a problem hiding this comment.
q.tags above this line is guarded so it isn't None:
if q.tags and q.tags.strip():
tag_list = [t.strip() for t in q.tags.split(',') if t.strip()]
for tag in tag_list:
queryset = queryset.filter(tags__text=tag)
if tag_list:
queryset = queryset.distinct()So the tags used for the for_list will always be at least a string. It can be an empty string but even that will create an empty array for tag_list.
| next_id = ids[idx + 1] if idx + 1 < len(ids) else None | ||
| previous_id = ids[idx - 1] if idx - 1 >= 0 else None |
There was a problem hiding this comment.
How does this work if the user is looking at either the first or last recording? Should we "wrap" around in those cases, or is that too much of a lift? I can see both cases
Co-authored-by: Michael Nagler <mike.nagler@kitware.com>
… tag_text ArrayAgg values
resolves #325
manage.py copy_recordings --count 1000 --tags "foo,bar,test"should copy and create 1000 recordings with a mixure of tags being test foo and bar.useState.tssubmission logic and computed values have been removed in favor of the get /recordings endpoint returning filtered data. Moving the filtering to the server instead of the client