diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py index 7c2776d9ce75be1c65464157549e073cbe63d47e..21e1e0aa483bbd4a38ca546f2e1ec97d94fdea03 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py @@ -156,16 +156,26 @@ def _get_data_ingested_per_site_and_type(request: Request, cycle: models.Cycle) """ result = [] - # Get DataProducts related to the cycle - dataproducts = models.Dataproduct.objects.filter(producer__subtask__task_blueprints__draft__scheduling_unit_draft__scheduling_set__project__cycles=cycle.pk) + # Get DataProducts related to the cycle with an ArchiveInfo + archive_info = models.DataproductArchiveInfo.objects.filter(dataproduct__producer__subtask__task_blueprints__draft__scheduling_unit_draft__scheduling_set__project__cycles=cycle.pk) + dataproducts = [ai.dataproduct for ai in archive_info] + # Filter DataProducts from Subtasks of type 'observation' + dp_from_observations = dataproducts.filter(producer__subtask__specifications_template__type='observation') + # Filter DataProducts from Subtasks of type 'pipeline' + dp_from_pipelines = dataproducts.filter(producer__subtask__specifications_template__type='pipeline') + + # TODO: Filter categories basing on DataType, TaskType, DataFormat. + # Filter DataProducts of type 'visibilities' and 'time series' from observations and pipelines + dp_visibilities = dp_from_observations.filter(datatype='visibilities') | dp_from_pipelines.filter(datatype='visibilities') + dp_time_series = dp_from_observations.filter(datatype='time series') | dp_from_pipelines.filter(datatype='time series') # TODO: Group dataproducts also per site. - # Iterate over types - datatypes = [c for c in models.Datatype.Choices] - for dt in datatypes: - dataproducts_per_type = dataproducts.filter(datatype=dt.value) - dataproducts_per_type_data = [serializers.DataproductSerializer(dp, context={'request': request}).data for dp in dataproducts_per_type] - result.append({'type': dt.value, 'dataproducts': dataproducts_per_type_data}) + # Iterate over categories + # categories = ('', '', '', '') + # for dt in datatypes: + # dataproducts_per_type = dataproducts.filter(datatype=dt.value) + # dataproducts_per_type_data = [serializers.DataproductSerializer(dp, context={'request': request}).data for dp in dataproducts_per_type] + # result.append({'type': dt.value, 'dataproducts': dataproducts_per_type_data}) return result @@ -190,8 +200,10 @@ def _get_usage_mode(cycle: models.Cycle) -> []: """ result = [] - # Get all the reservations related to the cycle + # Get all the reservations related to the projects in the cycle reservations = models.Reservation.objects.filter(project__cycles=cycle.pk) + # # Get all the reservations in stand-alone mode + # reservations_sa_mode = models.Reservation.objects.filter(specifications_doc__activity__type='stand-alone mode') # Get the first Monday before the cycle.start start, stop = cycle.start - timedelta(days=cycle.start.weekday()), cycle.stop