Skip to content

Conversation

mihow
Copy link
Collaborator

@mihow mihow commented May 17, 2025

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

  • Return fallback cover images in Taxa search API responses
  • Make project_id required for all taxa endpoints
  • Update UI to pass project_id in taxa search requests
  • Return global Taxon and TaxaLists with all responses
  • Fix validator in Django admin to allow a Taxon and TaxonList to be assigned to no projects
  • Add reusable field for adding cover images to all Taxa API serializers
  • Update all existing taxa to be global. Clusters will be the first project-specific taxa. Everything up until this point were added projects only because the admin validator mistakenly required it.

Related Issues

#838

Screenshots

image

Deployment Notes

Includes one migration that will set all existing Taxa to be global

Checklist

  • I have tested these changes appropriately.
  • I have added and/or modified relevant tests.
  • I updated relevant documentation or comments.
  • I have verified that this PR follows the project's coding standards.
  • Any dependent changes have already been merged to main.

Copy link

netlify bot commented May 17, 2025

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit 45e8286
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/68301fbe5769050008c87b99

Copy link

netlify bot commented May 17, 2025

Deploy Preview for antenna-ood canceled.

Name Link
🔨 Latest commit 45e8286
🔍 Latest deploy log https://app.netlify.com/projects/antenna-ood/deploys/68301fbea3e0240008c5d77f

@mihow mihow changed the title Clean up global vs project taxa & API responses Clean up global vs. project taxa & API responses May 17, 2025
@mihow mihow requested a review from Copilot May 17, 2025 18:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id for all taxa API endpoints and include global taxa where no project is assigned
  • Introduce a reusable TaxonCoverImageField for 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 projectId prop is used but not destructured from component props. Add projectId?: string to the function signature to avoid a ReferenceError.
projectId={projectId}

ami/main/api/serializers.py:473

  • The get_media_url function 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 in suggest to avoid N+1 queries when serializing parent taxon data.
self.get_queryset()

@mihow mihow merged commit 8ecd85c into deployments/ood.antenna.insectai.org May 23, 2025
6 checks passed
@mihow mihow deleted the feat/taxa-project-filters branch May 23, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant