File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1118,7 +1118,9 @@ def get_queryset(self) -> QuerySet["Occurrence"]:
1118
1118
qs = qs .with_detections_count ().with_timestamps () # type: ignore
1119
1119
qs = qs .with_identifications () # type: ignore
1120
1120
1121
- if self .action != "list" :
1121
+ if self .action == "list" :
1122
+ qs = qs .has_determination () # type: ignore
1123
+ else :
1122
1124
qs = qs .prefetch_related (
1123
1125
Prefetch (
1124
1126
"detections" , queryset = Detection .objects .order_by ("-timestamp" ).select_related ("source_image" )
Original file line number Diff line number Diff line change @@ -2235,6 +2235,12 @@ class OccurrenceQuerySet(models.QuerySet["Occurrence"]):
2235
2235
def valid (self ):
2236
2236
return self .exclude (detections__isnull = True )
2237
2237
2238
+ def has_determination (self ):
2239
+ """
2240
+ Filter out occurrences that are missing a determination.
2241
+ """
2242
+ return self .filter (determination__isnull = False )
2243
+
2238
2244
def with_detections_count (self ):
2239
2245
return self .annotate (detections_count = models .Count ("detections" , distinct = True ))
2240
2246
You can’t perform that action at this time.
0 commit comments