Skip to content

Commit cab5ef6

Browse files
fix: apply score threshold filter when include_unobserved is False
1 parent e310b34 commit cab5ef6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ami/main/api/views.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,12 +1345,12 @@ def get_queryset(self) -> QuerySet:
13451345
qs = qs.prefetch_related(
13461346
Prefetch(
13471347
"occurrences",
1348-
queryset=Occurrence.objects.filter_by_score_threshold(project, self.request).filter(
1349-
self.get_occurrence_filters(project)
1350-
)[:1],
1348+
queryset=Occurrence.objects.filter_by_score_threshold( # type: ignore
1349+
project, self.request
1350+
).filter(self.get_occurrence_filters(project))[:1],
13511351
to_attr="example_occurrences",
13521352
)
1353-
) # type: ignore
1353+
)
13541354
else:
13551355
# Add empty occurrences list to make the response consistent
13561356
qs = qs.annotate(example_occurrences=models.Value([], output_field=models.JSONField()))
@@ -1415,6 +1415,8 @@ def get_taxa_observed(self, qs: QuerySet, project: Project, include_unobserved=F
14151415
Occurrence.objects.filter(
14161416
occurrence_filters,
14171417
determination_id=models.OuterRef("id"),
1418+
).filter_by_score_threshold( # type: ignore
1419+
project, self.request
14181420
),
14191421
)
14201422
)

0 commit comments

Comments
 (0)