Clean up global vs. project taxa & API responses#853
Merged
mihow merged 10 commits intodeployments/ood.antenna.insectai.orgfrom May 23, 2025
Merged
Clean up global vs. project taxa & API responses#853mihow merged 10 commits intodeployments/ood.antenna.insectai.orgfrom
mihow merged 10 commits intodeployments/ood.antenna.insectai.orgfrom
Conversation
✅ Deploy Preview for antenna-preview canceled.
|
✅ Deploy Preview for antenna-ood canceled.
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR standardizes project scoping across Taxon endpoints, adds fallback cover image support, and updates the UI to pass projectId on searches.
- Require
project_idfor all taxa API endpoints and include global taxa where no project is assigned - Introduce a reusable
TaxonCoverImageFieldfor cover image URLs in serializers - Allow Taxon and TaxaList records to have no associated projects and update migrations/models accordingly
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/components/taxon-search/useTaxonSearch.ts | Add optional projectId parameter to search hook and URL |
| ui/src/components/taxon-search/taxon-select.tsx | Propagate new projectId prop through TaxonSelect |
| ui/src/components/taxon-search/taxon-search.tsx | Pass projectId into useTaxonSearch |
| ui/src/components/filtering/filters/taxon-filter.tsx | Attempt to pass projectId to TaxonSearch (prop not defined) |
| ami/main/models.py | Make projects M2M on Taxon and TaxaList blank=True |
| ami/main/migrations/0068_allow_taxa_without_project.py | Migration to alter projects fields to allow blank |
| ami/main/api/views.py | Enforce require_project, filter global+project taxa, update suggest |
| ami/main/api/serializers.py | Add TaxonCoverImageField, replace several SerializerMethodField implementations |
| ami/base/views.py | Update get_active_project signature and validation logic |
Comments suppressed due to low confidence (4)
ami/main/api/serializers.py:453
- [nitpick] New logic in
TaxonCoverImageField(fallback order and URL building) should be covered by unit tests to verify each branch (taxon URL, detection path, and None).
class TaxonCoverImageField(Field):
ui/src/components/filtering/filters/taxon-filter.tsx:52
- The
projectIdprop is used but not destructured from component props. AddprojectId?: stringto the function signature to avoid a ReferenceError.
projectId={projectId}
ami/main/api/serializers.py:473
- The
get_media_urlfunction is referenced here but not imported in this file. Please add the appropriate import to avoid a NameError.
return get_media_url(obj.best_detection_image_path)
ami/main/api/views.py:1283
- Consider re-adding
.select_related('parent')on the queryset insuggestto avoid N+1 queries when serializing parent taxon data.
self.get_queryset()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the Taxon search endpoint to return cover images in the same way the other Taxon endpoints do. Also updates Taxon endpoints with a number of important changes.
List of Changes
Related Issues
#838
Screenshots
Deployment Notes
Includes one migration that will set all existing Taxa to be global
Checklist