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

TMSS-770: Update get_saps for project reporting

parent 42c52b6f
No related branches found
No related tags found
3 merge requests!634WIP: COBALT commissioning delta,!522Resolve TMSS-770,!481Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
......@@ -405,5 +405,22 @@ def _get_saps(project_pk: int) -> []:
"""
Help function to retrieve SAPs.
"""
# TODO: For each unique target (SAP name) get the sum of target observation durations from the tasks.
return [{'sap_name': 'placeholder', 'total_exposure': 0}, ]
result = []
# TODO: Check if this is the proper way.
project_subs = models.SchedulingUnitBlueprint.objects.filter(draft__scheduling_set__project__pk=project_pk)
for sub in project_subs:
target_name, total_exposure = None, 0
try:
target_name = get_target_observation_task_name_from_requirements_doc(sub)
except Exception as e:
pass
control_subtasks = models.Subtask.objects.filter(task_blueprints__scheduling_unit_blueprint=sub).filter(specifications_template__name='observation control')
for cs in control_subtasks:
if target_name in cs.SAPs.all():
total_exposure += cs.duration.total_seconds()
if target_name:
result.append({'sap_name': target_name, 'total_exposure': total_exposure})
return result
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