Skip to content
Snippets Groups Projects
Commit ec37c985 authored by Mario Raciti's avatar Mario Raciti
Browse files

TMSS-692: Update durations representation accordingly to SI units

parent 9b0737ed
No related branches found
No related tags found
1 merge request!410Resolve TMSS-692
......@@ -23,16 +23,16 @@ def _get_subs_and_durations_from_project(project_pk: int) -> {}:
# 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})
subs_succeeded.append({'id': sub.pk, 'name': sub.name, 'duration': sub.duration.total_seconds()})
elif sub.status == 'cancelled': # Failed observations
total_failed_duration += sub.duration
subs_failed.append({'id': sub.pk, 'name': sub.name, 'duration': sub.duration})
subs_failed.append({'id': sub.pk, 'name': sub.name, 'duration': sub.duration.total_seconds()})
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
durations = {'total': str(total_duration), 'total_succeeded': str(total_succeeded_duration), 'total_not_cancelled': str(total_not_cancelled),
'total_failed': str(total_failed_duration), 'scheduling_unit_blueprints_finished': subs_succeeded,
'scheduling_unit_blueprints_failed': subs_failed}
durations = {'total': total_duration.total_seconds(), 'total_succeeded': total_succeeded_duration.total_seconds(),
'total_not_cancelled': total_not_cancelled.total_seconds(), 'total_failed': total_failed_duration.total_seconds(),
'scheduling_unit_blueprints_finished': subs_succeeded, 'scheduling_unit_blueprints_failed': subs_failed}
return durations
......
......@@ -554,13 +554,13 @@ class ProjectReportTest(unittest.TestCase):
self.assertEqual(result['quota'][0]['id'], self.project_quota.pk)
# Assert durations are well calculated
total = str(subtask.duration)
total = subtask.duration.total_seconds()
self.assertEqual(result['durations']['total'], total)
total_succeeded = str(subtask.duration)
total_succeeded = subtask.duration.total_seconds()
self.assertEqual(result['durations']['total_succeeded'], total_succeeded)
total_not_cancelled = str(subtask.duration)
total_not_cancelled = subtask.duration.total_seconds()
self.assertEqual(result['durations']['total_not_cancelled'], total_not_cancelled)
total_failed = str(timedelta(seconds=0))
total_failed = timedelta(seconds=0).total_seconds()
self.assertEqual(result['durations']['total_failed'], total_failed)
# There is only this finished SUB
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment