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

TMSS-728: Update JSON structure by moving SUBs outside durations

parent 40160068
Branches
Tags
1 merge request!419TMSS-728: Update JSON structure by moving SUBs outside durations
...@@ -12,7 +12,7 @@ def create_project_report(request: Request, project: models.Project) -> {}: ...@@ -12,7 +12,7 @@ def create_project_report(request: Request, project: models.Project) -> {}:
""" """
result = {'project': project.pk} result = {'project': project.pk}
result['quota'] = _get_quotas_from_project(request, project.pk) result['quota'] = _get_quotas_from_project(request, project.pk)
result['durations'] = _get_subs_and_durations_from_project(project.pk) result['SUBs'], result['durations'] = _get_subs_and_durations_from_project(project.pk)
result['LTA dataproducts'] = _get_lta_dataproducts(project.name) result['LTA dataproducts'] = _get_lta_dataproducts(project.name)
result['SAPs'] = _get_saps(project.pk) result['SAPs'] = _get_saps(project.pk)
...@@ -29,7 +29,7 @@ def _get_quotas_from_project(request: Request, project_pk: int) -> []: ...@@ -29,7 +29,7 @@ def _get_quotas_from_project(request: Request, project_pk: int) -> []:
return quotas return quotas
def _get_subs_and_durations_from_project(project_pk: int) -> {}: def _get_subs_and_durations_from_project(project_pk: int) -> ({}, {}):
""" """
Help function to retrieve durations and scheduling_units distinguished by success/fail. Help function to retrieve durations and scheduling_units distinguished by success/fail.
""" """
...@@ -52,9 +52,10 @@ def _get_subs_and_durations_from_project(project_pk: int) -> {}: ...@@ -52,9 +52,10 @@ def _get_subs_and_durations_from_project(project_pk: int) -> {}:
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_seconds(), 'total_succeeded': total_succeeded_duration.total_seconds(), 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(), '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} subs = {'finished': subs_succeeded, 'failed': subs_failed}
return durations
return subs, durations
def _get_lta_dataproducts(project_name: str) -> {}: def _get_lta_dataproducts(project_name: str) -> {}:
......
...@@ -578,9 +578,9 @@ class ProjectReportTest(unittest.TestCase): ...@@ -578,9 +578,9 @@ class ProjectReportTest(unittest.TestCase):
self.assertAlmostEqual(result['durations']['total_failed'], total_failed) self.assertAlmostEqual(result['durations']['total_failed'], total_failed)
# There is only one finished SUB # There is only one finished SUB
self.assertEqual(result['durations']['scheduling_unit_blueprints_finished'][0]['id'], succeeded_sub.pk) self.assertEqual(result['SUBs']['finished'][0]['id'], succeeded_sub.pk)
# There is only one cancelled SUB # There is only one cancelled SUB
self.assertEqual(result['durations']['scheduling_unit_blueprints_failed'][0]['id'], cancelled_sub.pk) self.assertEqual(result['SUBs']['failed'][0]['id'], cancelled_sub.pk)
# There are just two dataproducts # There are just two dataproducts
self.assertEqual(result['LTA dataproducts']['size__sum'], dataproduct1.size + dataproduct2.size) self.assertEqual(result['LTA dataproducts']['size__sum'], dataproduct1.size + dataproduct2.size)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment