Skip to content

Commit cd56199

Browse files
committed
Merge branch 'deployments/ood.antenna.insectai.org' of https://github.com/RolnickLab/antenna into deployments/ood.antenna.insectai.org
2 parents 4fa88a0 + ce334db commit cd56199

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ami/main/api/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,9 @@ def get_queryset(self) -> QuerySet["Occurrence"]:
11181118
qs = qs.with_detections_count().with_timestamps() # type: ignore
11191119
qs = qs.with_identifications() # type: ignore
11201120

1121-
if self.action != "list":
1121+
if self.action == "list":
1122+
qs = qs.has_determination() # type: ignore
1123+
else:
11221124
qs = qs.prefetch_related(
11231125
Prefetch(
11241126
"detections", queryset=Detection.objects.order_by("-timestamp").select_related("source_image")

ami/main/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,12 @@ class OccurrenceQuerySet(models.QuerySet["Occurrence"]):
22352235
def valid(self):
22362236
return self.exclude(detections__isnull=True)
22372237

2238+
def has_determination(self):
2239+
"""
2240+
Filter out occurrences that are missing a determination.
2241+
"""
2242+
return self.filter(determination__isnull=False)
2243+
22382244
def with_detections_count(self):
22392245
return self.annotate(detections_count=models.Count("detections", distinct=True))
22402246

0 commit comments

Comments
 (0)