diff --git a/backend/core/helpers.py b/backend/core/helpers.py index 4592de23eb..83b3cdf21e 100644 --- a/backend/core/helpers.py +++ b/backend/core/helpers.py @@ -508,16 +508,16 @@ def aggregate_risks_per_field( count = ( RiskScenario.objects.filter(id__in=object_ids_view) .filter(residual_level=i) - .filter(risk_assessment__risk_matrix__name=["name"]) + # .filter(risk_assessment__risk_matrix__name=["name"]) .count() - ) + ) # What the second filter does ? Is this usefull ? else: count = ( RiskScenario.objects.filter(id__in=object_ids_view) .filter(current_level=i) - .filter(risk_assessment__risk_matrix__name=["name"]) + # .filter(risk_assessment__risk_matrix__name=["name"]) .count() - ) + ) # What the second filter does ? Is this usefull ? if "count" not in values[m["risk"][i][field]]: values[m["risk"][i][field]]["count"] = count @@ -528,22 +528,26 @@ def aggregate_risks_per_field( def risks_count_per_level(user: User, risk_assessments: list | None = None): - current_level = list() - residual_level = list() + current_level = [] + residual_level = [] - for r in aggregate_risks_per_field( + for level_name, level_data in aggregate_risks_per_field( user, "name", risk_assessments=risk_assessments ).items(): - current_level.append( - {"name": r[0], "value": r[1]["count"], "color": r[1]["color"]} - ) + current_level.append({ + "name": level_name, + "value": level_data["count"], + "color": level_data["color"] + }) - for r in aggregate_risks_per_field( + for level_name, level_data in aggregate_risks_per_field( user, "name", residual=True, risk_assessments=risk_assessments ).items(): - residual_level.append( - {"name": r[0], "value": r[1]["count"], "color": r[1]["color"]} - ) + residual_level.append({ + "name": level_name, + "value": level_data["count"], + "color":level_data["color"] + }) return {"current": current_level, "residual": residual_level} diff --git a/backend/core/views.py b/backend/core/views.py index 48a7d62e28..0c2f40d3d8 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -682,7 +682,7 @@ def impact(self, request, pk): return Response(choices) @action(detail=False, name="Get risk count per level") - def count_per_level(self, request): # _per_level + def count_per_level(self, request): return Response({"results": risks_count_per_level(request.user)}) diff --git a/frontend/src/lib/components/Chart/DonutChart.svelte b/frontend/src/lib/components/Chart/DonutChart.svelte index b479d867e6..0337c4f086 100644 --- a/frontend/src/lib/components/Chart/DonutChart.svelte +++ b/frontend/src/lib/components/Chart/DonutChart.svelte @@ -1,14 +1,19 @@ -
+
diff --git a/frontend/src/routes/(app)/analytics/+page.svelte b/frontend/src/routes/(app)/analytics/+page.svelte index f8881cf56a..1c7593559e 100644 --- a/frontend/src/routes/(app)/analytics/+page.svelte +++ b/frontend/src/routes/(app)/analytics/+page.svelte @@ -288,6 +288,7 @@ Current risk level per risk scenario Residual risk level per risk scenario Residual risk level per risk scenario