Skip to content
Snippets Groups Projects
Commit 153740da authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-2886: little query optimization

parent 84e1810b
No related branches found
No related tags found
No related merge requests found
...@@ -757,10 +757,12 @@ def failure_report(request): ...@@ -757,10 +757,12 @@ def failure_report(request):
def public_schedule(request): def public_schedule(request):
'''return the current and future running and scheduled units in either html table or json depending on the request accept header''' '''return the current and future running and scheduled units in either html table or json depending on the request accept header'''
# get all current and future running and scheduled units # get all current and future running and scheduled units
scheduled_or_running_units = models.SchedulingUnitBlueprint.objects.filter(status__value__in=models.SchedulingUnitStatus.ACTIVE_STATUS_VALUES) \ scheduled_or_running_units = models.SchedulingUnitBlueprint.objects.prefetch_related('task_blueprints__specifications_template__type') \
.select_related(models.SchedulingUnitBlueprint.path_to_project, 'status', 'specifications_template', 'specifications_template') \
.filter(status__value__in=models.SchedulingUnitStatus.ACTIVE_STATUS_VALUES) \
.filter(obsolete_since__isnull=True) \ .filter(obsolete_since__isnull=True) \
.filter(on_sky_stop_time__gte=datetime.utcnow()) \ .filter(on_sky_stop_time__gte=datetime.utcnow()) \
.order_by('on_sky_start_time').all() .order_by('on_sky_start_time').all()[:3]
# return json if requested # return json if requested
if 'json' in request.headers.get('Accept','').lower(): if 'json' in request.headers.get('Accept','').lower():
......
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