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

TMSS-610: Update get_cycles_report API

parent 1104b6b1
Branches
Tags
3 merge requests!634WIP: COBALT commissioning delta,!492Resolve TMSS-610,!481Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
...@@ -161,7 +161,7 @@ def _get_data_ingested_per_site_and_type(request: Request, cycle: models.Cycle) ...@@ -161,7 +161,7 @@ def _get_data_ingested_per_site_and_type(request: Request, cycle: models.Cycle)
# archive_info = models.DataproductArchiveInfo.objects.filter(dataproduct__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] # dataproducts = [ai.dataproduct for ai in archive_info]
# Get DataProducts related to the cycle # 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) dataproducts = models.Dataproduct.objects.filter(producer__subtask__task_blueprints__draft__scheduling_unit_draft__scheduling_set__project__cycles=cycle.pk)
# Combine and filter DataPrducts accordingly # Combine and filter DataPrducts accordingly
......
...@@ -280,19 +280,16 @@ def get_target_rise_and_set(request): ...@@ -280,19 +280,16 @@ def get_target_rise_and_set(request):
return JsonResponse(rise_set_dict) return JsonResponse(rise_set_dict)
# TODO: Change method to POST, add other responses and change 'in_=body'.
@swagger_auto_schema(method='GET', responses={200: 'A JSON object with cycles information for reporting.'}, @swagger_auto_schema(method='GET', responses={200: 'A JSON object with cycles information for reporting.'},
manual_parameters=[Parameter(name='cycles', required=True, type='array', in_='query', manual_parameters=[Parameter(name='cycles', required=True, type='array', in_='query',
items={'type': 'string'}, description="Cycles' primary keys.")]) items={'type': 'string'}, description="Cycles' primary keys.")])
@api_view(['GET']) @api_view(['GET'])
def get_cycles_report(request): def get_cycles_report(request):
# TODO: Sanitise inputs
cycles = str(request.GET.get('cycles')).split(',') cycles = str(request.GET.get('cycles')).split(',')
results = {} results = {}
for c_pk in cycles: for c_pk in cycles:
c = get_object_or_404(models.Cycle, pk=c_pk) c = get_object_or_404(models.Cycle, pk=c_pk)
info = create_cycle_report(request, c) results[c_pk] = create_cycle_report(request, c)
results[c_pk] = info
return JsonResponse(results) return JsonResponse(results)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment