diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py index c94deff12f0c9a71a3e94e983588d50f67910563..7f941d250c3b565ce31464dfeb71e1d1105828de 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py @@ -69,10 +69,13 @@ class CycleReport(): # by the cycle. (No need to handle the parts outside the cycle because these time are not included anyway.) # Note: we do not use self.subs here because we purposefully do not want to filter on projects etc. for sub in models.SchedulingUnitBlueprint.objects.filter(on_sky_start_time__lt=stop, on_sky_stop_time__gt=start)\ + .filter(on_sky_start_time__lt=F('on_sky_stop_time'))\ .only('on_sky_start_time', 'on_sky_stop_time'): + new_idle_ranges = [] + sub_range = DateTimeRange(sub.on_sky_start_time, sub.on_sky_stop_time) for range in idle_ranges: - new_idle_ranges += range.subtract(DateTimeRange(sub.on_sky_start_time, sub.on_sky_stop_time)) + new_idle_ranges += range.subtract(sub_range) idle_ranges = new_idle_ranges idle_seconds = sum([range.get_timedelta_second() for range in idle_ranges]) @@ -360,8 +363,9 @@ class CycleReport(): standalone_reservations = [res for res in standalone_reservations if len(res.specifications_doc.get('resources', {}).get('stations', [])) >= 3] # Determine scheduling units in reporting period - # Note: we do not use self.subs because we purposefully do not want to filter for projects etc here. # todo: correct? - subs_in_period = models.SchedulingUnitBlueprint.objects.filter(on_sky_start_time__lt=stop, on_sky_stop_time__gt=start) + # Note: we do not use self.subs because we purposefully do not want to filter for projects etc here. + subs_in_period = models.SchedulingUnitBlueprint.objects.filter(on_sky_start_time__lt=stop, on_sky_stop_time__gt=start)\ + .filter(on_sky_start_time__lt=F('on_sky_stop_time')) ilt_stations = ['DE601', 'DE602', 'DE603', 'DE604', 'DE605', 'DE609', 'FR606', 'SE607', 'UK608', 'PL610', 'PL611', 'PL612', 'IE613', 'LV614'] subs_in_period_int = subs_in_period.filter(task_blueprints__subtasks__specifications_doc__stations__overlap=ilt_stations) \ | subs_in_period.filter (task_blueprints__subtasks__specifications_doc__station_list__overlap=ilt_stations)