Skip to content

Conversation

annavik
Copy link
Member

@annavik annavik commented Sep 12, 2025

Summary

In #929, we setup a view to make it possible to adjust default filters for a project. In this PR, we apply the filter for score threshold. The changes includes both frontend and backend updates.

Related Issues

Fixes #926

List of Changes

  • Added get_default_classification_threshold(project, request) to read threshold from project settings (falling back to request params if apply_defaults=false).

  • Added filter_by_score_threshold() filtering queryset method to OccurrenceQuerySet.

  • Applied default threshold filtering in:

    OccurrenceViewSet

    TaxonViewSet

    SourceImageViewSet

    SourceImageCollectionViewSet

    EventViewSet

    SummaryView

  • Removed OccurrenceDeterminationScoreFilter.

Detailed Description

This PR is the first step toward using default project-level settings filters across the platform.
It introduces support for applying the project’s configured default classification score threshold to multiple API endpoints. When a threshold is defined in the project settings, all relevant endpoints (Occurrences, Taxa, Events, Source Images, Collections, and Summary) automatically filter out records below that threshold.

At the same time, flexibility is preserved: users can bypass the defaults by passing apply_defaults=false in their request, which reverts filtering behavior back to the per-request classification_threshold parameter.

How to Test the Changes

  1. Go to the Project Details admin page and set a default classification score threshold.

  2. Check that the Occurrence, Taxon, Event, and Summary endpoints all respect the threshold.

  3. Add ?apply_defaults=false to API requests and confirm that results are no longer filtered by the project defaults.

  4. Remove the flag (or set apply_defaults=true) and confirm that defaults are applied again.

Screenshots

TBD

Deployment Notes

TBD

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 Sep 12, 2025

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit 48bfa18
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/68cc851f1a66eb0008cf39e6

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mihow mihow requested a review from Copilot September 17, 2025 07:09
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

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +79 to +80
if project is None:
return 0.0
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

This condition will never be reached because the function signature shows project as a required parameter without a default value, but the docstring and logic suggest it should handle None values. Either make project optional with a default of None or remove this check.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@mihow mihow left a comment

Choose a reason for hiding this comment

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

  • Add a few automated tests. Try testing the summary view counts like we did in the Draft Projects PR.
  • I see that the taxa in the taxa list view are showing with scores less than the default threshold.
image

@mohamedelabbas1996
Copy link
Contributor

mohamedelabbas1996 commented Sep 18, 2025

  • I see that the taxa in the taxa list view are showing with scores less than the default threshold.

This is weird since the default score threshold filter is already applied in get_taxa_observed

.filter_by_score_threshold(project, self.request) # type: ignore

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.

Implement the Score threshold filter in the backend
3 participants