Skip to content

Commit

Permalink
Experimental Insights
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-smith committed Oct 1, 2024
1 parent 5f6acac commit 944afe3
Show file tree
Hide file tree
Showing 9 changed files with 1,472 additions and 35 deletions.
72 changes: 72 additions & 0 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,78 @@ def export_csv(self, request):
writer.writerow(row)
return response

@action(detail=False, methods=["get"])
def get_controls_info(self, request):
nodes = list()
links = list()
for ac in AppliedControl.objects.all():
related_items_count = 0
for ca in ComplianceAssessment.objects.filter(
requirement_assessments__applied_controls=ac
).distinct():
audit_coverage = (
RequirementAssessment.objects.filter(compliance_assessment=ca)
.filter(applied_controls=ac)
.count()
)
related_items_count += audit_coverage
links.append(
{
"source": ca.id,
"target": ac.id,
"coverage": audit_coverage,
}
)
for ra in RiskAssessment.objects.filter(
risk_scenarios__applied_controls=ac
).distinct():
risk_coverage = (
RiskScenario.objects.filter(risk_assessment=ra)
.filter(applied_controls=ac)
.count()
)
related_items_count += risk_coverage
links.append(
{
"source": ra.id,
"target": ac.id,
"coverage": risk_coverage,
}
)
nodes.append(
{
"id": ac.id,
"label": ac.name,
"shape": "hexagon",
"counter": related_items_count,
"color": "#47e845",
}
)
for audit in ComplianceAssessment.objects.all():
nodes.append(
{
"id": audit.id,
"label": audit.name,
"shape": "circle",
"color": "#5D4595",
}
)
for ra in RiskAssessment.objects.all():
nodes.append(
{
"id": ra.id,
"label": ra.name,
"shape": "square",
"color": "#E6499F",
}
)
return Response(
{
"nodes": nodes,
"links": links,
}
)


class PolicyViewSet(AppliedControlViewSet):
model = Policy
Expand Down
2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
"@fortawesome/fontawesome-free": "^6.6.0",
"@inlang/paraglide-js-adapter-vite": "^1.2.40",
"@inlang/paraglide-sveltekit": "0.11.0",
"@unovis/svelte": "1.4.3-beta.0",
"@unovis/ts": "1.4.3-beta.0",
"dotenv": "^16.4.5",
"echarts": "^5.5.1",
"svelte-multiselect": "^10.2.0",
Expand Down
Loading

0 comments on commit 944afe3

Please sign in to comment.