From d3197ce4fca6a49ea1d490c30f4e3e457c8b07c5 Mon Sep 17 00:00:00 2001
From: Mario Raciti <mario.raciti@inaf.it>
Date: Wed, 31 Mar 2021 11:30:00 +0200
Subject: [PATCH] TMSS-692: Cleanup

---
 SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
index 6c4e8f3bb4d..6b088f6667c 100644
--- a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+++ b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
@@ -15,10 +15,11 @@ def _get_subs_and_durations_from_project(project_pk: int) -> {}:
     # Get SUBs related to the project
     scheduling_unit_blueprints = models.SchedulingUnitBlueprint.objects.filter(draft__scheduling_set__project__pk=project_pk)
     # TODO: Split into total, prio A, prio B? See TMSS-592.
-    total_duration, total_succeeded_duration, total_not_cancelled, total_failed_duration = timedelta(), timedelta(), timedelta(), timedelta()
+    total_duration, total_succeeded_duration, total_failed_duration = timedelta(), timedelta(), timedelta()
     subs_succeeded, subs_failed = [], []
 
     for sub in scheduling_unit_blueprints:  # Distinguish between succeeded and failed observations
+        # TODO: Use QA workflow flag instead of the finished status? See TMSS-592.
         if sub.status == 'finished':        # Succeeded observations
             total_succeeded_duration += sub.duration
             subs_succeeded.append({'id': sub.pk, 'name': sub.name, 'duration': sub.duration})
@@ -27,10 +28,10 @@ def _get_subs_and_durations_from_project(project_pk: int) -> {}:
             subs_failed.append({'id': sub.pk, 'name': sub.name, 'duration': sub.duration})
         total_duration += sub.duration      # Total duration without considering the status of the obs.
 
-    total_not_cancelled = total_duration-total_failed_duration  # Calculate not_cancelled duration
+    total_not_cancelled = total_duration - total_failed_duration  # Calculate not_cancelled duration
     durations = {'total': total_duration, 'total_succeeded': total_succeeded_duration, 'total_not_cancelled': total_not_cancelled,
-              'total_failed': total_failed_duration, 'scheduling_unit_blueprints_finished': subs_succeeded,
-              'scheduling_unit_blueprints_failed': subs_failed}
+                 'total_failed': total_failed_duration, 'scheduling_unit_blueprints_finished': subs_succeeded,
+                 'scheduling_unit_blueprints_failed': subs_failed}
     return durations
 
 
-- 
GitLab