Skip to content

Commit a1754e0

Browse files
simple metrics: count closed properly (#12595)
1 parent 826dca6 commit a1754e0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

dojo/metrics/views.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ def simple_metrics(request):
185185
total_medium = []
186186
total_low = []
187187
total_info = []
188-
total_closed = []
189188
total_opened = []
190189
findings_broken_out = {}
191190

@@ -197,10 +196,20 @@ def simple_metrics(request):
197196
date__year=now.year,
198197
)
199198

199+
closed = Finding.objects.filter(test__engagement__product__prod_type=pt,
200+
false_p=False,
201+
duplicate=False,
202+
out_of_scope=False,
203+
mitigated__month=now.month,
204+
mitigated__year=now.year,
205+
)
206+
200207
if get_system_setting("enforce_verified_status", True) or get_system_setting("enforce_verified_status_metrics", True):
201208
total = total.filter(verified=True)
209+
closed = closed.filter(verified=True)
202210

203211
total = total.distinct()
212+
closed = closed.distinct()
204213

205214
for f in total:
206215
if f.severity == "Critical":
@@ -214,9 +223,6 @@ def simple_metrics(request):
214223
else:
215224
total_info.append(f)
216225

217-
if f.mitigated and f.mitigated.year == now.year and f.mitigated.month == now.month:
218-
total_closed.append(f)
219-
220226
if f.date.year == now.year and f.date.month == now.month:
221227
total_opened.append(f)
222228

@@ -228,7 +234,7 @@ def simple_metrics(request):
228234
findings_broken_out["S4"] = len(total_info)
229235

230236
findings_broken_out["Opened"] = len(total_opened)
231-
findings_broken_out["Closed"] = len(total_closed)
237+
findings_broken_out["Closed"] = len(closed)
232238

233239
findings_by_product_type[pt] = findings_broken_out
234240

0 commit comments

Comments
 (0)