Skip to content

Commit

Permalink
Set the objects_meta attribute at the migration of the library model …
Browse files Browse the repository at this point in the history
…to the loadedlibrary model
  • Loading branch information
monsieurswag committed May 15, 2024
1 parent debaa8f commit 42731aa
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down

0 comments on commit 42731aa

Please sign in to comment.