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

TMSS-610: Update data_ingested_per_site_and_type info

parent cd6dd8a7
No related branches found
No related tags found
3 merge requests!634WIP: COBALT commissioning delta,!492Resolve TMSS-610,!481Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
...@@ -156,16 +156,26 @@ def _get_data_ingested_per_site_and_type(request: Request, cycle: models.Cycle) ...@@ -156,16 +156,26 @@ def _get_data_ingested_per_site_and_type(request: Request, cycle: models.Cycle)
""" """
result = [] result = []
# Get DataProducts related to the cycle # Get DataProducts related to the cycle with an ArchiveInfo
dataproducts = models.Dataproduct.objects.filter(producer__subtask__task_blueprints__draft__scheduling_unit_draft__scheduling_set__project__cycles=cycle.pk) 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. # TODO: Group dataproducts also per site.
# Iterate over types # Iterate over categories
datatypes = [c for c in models.Datatype.Choices] # categories = ('', '', '', '')
for dt in datatypes: # for dt in datatypes:
dataproducts_per_type = dataproducts.filter(datatype=dt.value) # 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] # 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}) # result.append({'type': dt.value, 'dataproducts': dataproducts_per_type_data})
return result return result
...@@ -190,8 +200,10 @@ def _get_usage_mode(cycle: models.Cycle) -> []: ...@@ -190,8 +200,10 @@ def _get_usage_mode(cycle: models.Cycle) -> []:
""" """
result = [] 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) 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 # Get the first Monday before the cycle.start
start, stop = cycle.start - timedelta(days=cycle.start.weekday()), cycle.stop start, stop = cycle.start - timedelta(days=cycle.start.weekday()), cycle.stop
......
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