@@ -1069,9 +1069,9 @@ def get_serializer_class(self):
1069
1069
else :
1070
1070
return OccurrenceSerializer
1071
1071
1072
- def get_queryset (self ) -> QuerySet :
1072
+ def get_queryset (self ) -> QuerySet [ "Occurrence" ] :
1073
1073
project = self .get_active_project ()
1074
- qs = super ().get_queryset ()
1074
+ qs = super ().get_queryset (). valid () # type: ignore
1075
1075
if project :
1076
1076
qs = qs .filter (project = project )
1077
1077
qs = qs .select_related (
@@ -1085,10 +1085,7 @@ def get_queryset(self) -> QuerySet:
1085
1085
if self .action == "list" :
1086
1086
qs = (
1087
1087
qs .all ()
1088
- .exclude (detections = None )
1089
- .exclude (event = None )
1090
1088
.filter (determination_score__gte = get_active_classification_threshold (self .request ))
1091
- .exclude (first_appearance_timestamp = None ) # This must come after annotations
1092
1089
.order_by ("-determination_score" )
1093
1090
)
1094
1091
@@ -1426,11 +1423,7 @@ def get(self, request):
1426
1423
"events_count" : Event .objects .filter (deployment__project = project , deployment__isnull = False ).count (),
1427
1424
"captures_count" : SourceImage .objects .filter (deployment__project = project ).count (),
1428
1425
# "detections_count": Detection.objects.filter(occurrence__project=project).count(),
1429
- "occurrences_count" : Occurrence .objects .filter (
1430
- project = project ,
1431
- # determination_score__gte=confidence_threshold,
1432
- event__isnull = False ,
1433
- ).count (),
1426
+ "occurrences_count" : Occurrence .objects .valid ().filter (project = project ).count (), # type: ignore
1434
1427
"taxa_count" : Occurrence .objects .all ().unique_taxa (project = project ).count (), # type: ignore
1435
1428
}
1436
1429
else :
@@ -1440,10 +1433,7 @@ def get(self, request):
1440
1433
"events_count" : Event .objects .filter (deployment__isnull = False ).count (),
1441
1434
"captures_count" : SourceImage .objects .count (),
1442
1435
# "detections_count": Detection.objects.count(),
1443
- "occurrences_count" : Occurrence .objects .filter (
1444
- # determination_score__gte=confidence_threshold,
1445
- event__isnull = False
1446
- ).count (),
1436
+ "occurrences_count" : Occurrence .objects .valid ().count (), # type: ignore
1447
1437
"taxa_count" : Occurrence .objects .all ().unique_taxa ().count (), # type: ignore
1448
1438
"last_updated" : timezone .now (),
1449
1439
}
0 commit comments