fix(threatscore): exclude muted findings from aggregated statistics in threatscore utils (#9296)

This commit is contained in:
Adrián Jesús Peña Rodríguez
2025-11-24 13:25:20 +01:00
committed by GitHub
parent 2f184a493b
commit 75abd8f54d
3 changed files with 10 additions and 4 deletions
@@ -41,10 +41,15 @@ def _aggregate_requirement_statistics_from_database(
with rls_transaction(tenant_id, using=READ_REPLICA_ALIAS):
aggregated_statistics_queryset = (
Finding.all_objects.filter(tenant_id=tenant_id, scan_id=scan_id)
Finding.all_objects.filter(
tenant_id=tenant_id, scan_id=scan_id, muted=False
)
.values("check_id")
.annotate(
total_findings=Count("id"),
total_findings=Count(
"id",
filter=Q(status__in=[StatusChoices.PASS, StatusChoices.FAIL]),
),
passed_findings=Count("id", filter=Q(status=StatusChoices.PASS)),
)
)
+2 -2
View File
@@ -238,8 +238,8 @@ class TestAggregateRequirementStatistics:
str(tenant.id), str(scan.id)
)
# Only PASS status is counted as passed
assert result == {"check_mixed": {"passed": 1, "total": 3}}
# Only PASS status is counted as passed, MANUAL findings are excluded from total
assert result == {"check_mixed": {"passed": 1, "total": 2}}
@pytest.mark.django_db