Skip to content

Commit

Permalink
fix(overview): retrieve aggregated findings from completed scans (#5975)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicferpoy authored Nov 30, 2024
1 parent 3547153 commit add2134
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions api/src/backend/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
Scan,
ScanSummary,
SeverityChoices,
StateChoices,
StatusChoices,
Task,
User,
Expand All @@ -76,8 +77,8 @@
from api.v1.serializers import (
ComplianceOverviewFullSerializer,
ComplianceOverviewSerializer,
FindingSerializer,
FindingDynamicFilterSerializer,
FindingSerializer,
InvitationAcceptSerializer,
InvitationCreateSerializer,
InvitationSerializer,
Expand Down Expand Up @@ -1480,7 +1481,9 @@ def findings(self, request):
filtered_queryset = self.filter_queryset(queryset)

latest_scan_subquery = (
Scan.objects.filter(provider_id=OuterRef("scan__provider_id"))
Scan.objects.filter(
state=StateChoices.COMPLETED, provider_id=OuterRef("scan__provider_id")
)
.order_by("-id")
.values("id")[:1]
)
Expand Down Expand Up @@ -1520,7 +1523,9 @@ def findings_severity(self, request):
filtered_queryset = self.filter_queryset(queryset)

latest_scan_subquery = (
Scan.objects.filter(provider_id=OuterRef("scan__provider_id"))
Scan.objects.filter(
state=StateChoices.COMPLETED, provider_id=OuterRef("scan__provider_id")
)
.order_by("-id")
.values("id")[:1]
)
Expand Down

0 comments on commit add2134

Please # to comment.