From 47e603ea4636f4f97342c6e6d5d20a83994ab586 Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:11:21 +0200 Subject: [PATCH 1/3] Update status.py improve instance status (python manage.py status) --- backend/core/management/commands/status.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/core/management/commands/status.py b/backend/core/management/commands/status.py index f97ae92bf..41fe1c9f7 100644 --- a/backend/core/management/commands/status.py +++ b/backend/core/management/commands/status.py @@ -21,8 +21,11 @@ def handle(self, *args, **kwargs): nb_risk_assessments = RiskAssessment.objects.all().count() nb_risk_scenarios = RiskScenario.objects.all().count() nb_risk_acceptances = RiskAcceptance.objects.all().count() + created_at = Folder.get_root_folder().created_at + last_login = max(x['last_login'] for x in User.objects.all().values('last_login')) self.stdout.write( - f"users={nb_users} first_logins={nb_first_login} libraries={nb_libraries} " + f"created_at={created_at.strftime('%Y-%m-%dT%H:%M')} last_login={last_login.strftime('%Y-%m-%dT%H:%M')} " + + f"users={nb_users} first_logins={nb_first_login} libraries={nb_libraries} " + f"domains={nb_domains} projects={nb_projects} assets={nb_assets} " + f"threats={nb_threats} functions={nb_functions} measures={nb_measures} " + f"evidences={nb_evidences} compliance={nb_compliance_assessments} risk={nb_risk_assessments} " From 69c275061e75f89fbdf1bf2ae52bbeb15e8e3c3a Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:13:40 +0200 Subject: [PATCH 2/3] Update status.py ruff --- backend/core/management/commands/status.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/core/management/commands/status.py b/backend/core/management/commands/status.py index 41fe1c9f7..1e4675bca 100644 --- a/backend/core/management/commands/status.py +++ b/backend/core/management/commands/status.py @@ -22,7 +22,9 @@ def handle(self, *args, **kwargs): nb_risk_scenarios = RiskScenario.objects.all().count() nb_risk_acceptances = RiskAcceptance.objects.all().count() created_at = Folder.get_root_folder().created_at - last_login = max(x['last_login'] for x in User.objects.all().values('last_login')) + last_login = max( + x["last_login"] for x in User.objects.all().values("last_login") + ) self.stdout.write( f"created_at={created_at.strftime('%Y-%m-%dT%H:%M')} last_login={last_login.strftime('%Y-%m-%dT%H:%M')} " + f"users={nb_users} first_logins={nb_first_login} libraries={nb_libraries} " From 90c37bf87479d47ca267bc04a5fecdc6b2c96837 Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Wed, 24 Apr 2024 18:25:41 +0200 Subject: [PATCH 3/3] Fix the status exception when no user ever logged in to the application --- backend/core/management/commands/status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/core/management/commands/status.py b/backend/core/management/commands/status.py index 1e4675bca..0a7a92d27 100644 --- a/backend/core/management/commands/status.py +++ b/backend/core/management/commands/status.py @@ -26,7 +26,7 @@ def handle(self, *args, **kwargs): x["last_login"] for x in User.objects.all().values("last_login") ) self.stdout.write( - f"created_at={created_at.strftime('%Y-%m-%dT%H:%M')} last_login={last_login.strftime('%Y-%m-%dT%H:%M')} " + f"created_at={created_at.strftime('%Y-%m-%dT%H:%M')} last_login={last_login.strftime('%Y-%m-%dT%H:%M') if last_login else last_login} " + f"users={nb_users} first_logins={nb_first_login} libraries={nb_libraries} " + f"domains={nb_domains} projects={nb_projects} assets={nb_assets} " + f"threats={nb_threats} functions={nb_functions} measures={nb_measures} "