diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py index 3e4b6698a77f2c7a0abd49bf5504ad5a3643c87a..48fe4f7c050c1430c923daeaa83dd930851a0a4f 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py @@ -32,10 +32,12 @@ def _get_telescope_time_distribution(cycle: models.Cycle): """ result = {} - # ProjectCategories - for c in models.ProjectCategory.Choices: + # Consider FILLER as a category + categories = ['FILLER',] + [c for c in models.ProjectCategory.Choices] + for c in categories: total, succeeded, failed = 0, 0, 0 - projects = models.Project.objects.filter(cycles=cycle, project_category=c.value) + projects = models.Project.objects.filter(cycles=cycle, project_category=c.value) if c != 'FILLER' \ + else models.Project.objects.filter(cycles=cycle, filler=True) for p in projects: # Get durations for single project and aggregate to get the totals _, durations = _get_subs_and_durations_from_project(p) @@ -43,19 +45,8 @@ def _get_telescope_time_distribution(cycle: models.Cycle): succeeded += durations['total_succeeded'] failed += durations['total_failed'] idle = total - succeeded - failed - result[c.name] = {'durations': {'total': total, 'succeeded': succeeded, 'failed': failed, 'idle': idle}} - - # Filler - total, succeeded, failed = 0, 0, 0 - projects = models.Project.objects.filter(cycles=cycle, filler=True) - for p in projects: - # Get durations for single project and aggregate to get the totals - _, durations = _get_subs_and_durations_from_project(p) - total += durations['total'] - succeeded += durations['total_succeeded'] - failed += durations['total_failed'] - idle = total - succeeded - failed - result['FILLER'] = {'durations': {'total': total, 'succeeded': succeeded, 'failed': failed, 'idle': idle}} + result[c.name if c != 'FILLER' else 'FILLER'] = {'durations': {'total': total, 'succeeded': succeeded, + 'failed': failed, 'idle': idle}} return result