From 42731aa4376c9970be72d3f766abe18c3032d5e2 Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Wed, 15 May 2024 11:20:39 +0200 Subject: [PATCH] Set the objects_meta attribute at the migration of the library model to the loadedlibrary model --- .../0012_alter_appliedcontrol_updated_at_and_more.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/core/migrations/0012_alter_appliedcontrol_updated_at_and_more.py b/backend/core/migrations/0012_alter_appliedcontrol_updated_at_and_more.py index 3c3a4ed38..23137413d 100644 --- a/backend/core/migrations/0012_alter_appliedcontrol_updated_at_and_more.py +++ b/backend/core/migrations/0012_alter_appliedcontrol_updated_at_and_more.py @@ -69,6 +69,13 @@ def adapt_libraries(apps, schema_editor): library.urn in BUILTIN_LIBRARY_URNS ) # There is no perfect way to verify is a loaded custom library is builtin or not # There is no way to generate the objects_meta dictionary without reading all files from ./backend/library/libraries, but we can generate the missing objects_meta values at the same time we generate the StoredLibrary objects. + + library.objects_meta = { + "frameworks": library.frameworks.count(), + "threats": library.threats.count(), + "reference_controls": library.reference_controls.count(), + "risk_matrix": library.risk_matrices.count() + } library.save()