Commit 3e8dbfec authored by Stevan Radakovic's avatar Stevan Radakovic Committed by Neil Williams
Browse files

all_devices() api call to do one big query instead of many small ones.

device.is_visible_to was called for all devices which generated
approx. num_of_devices * num_of_devices_of_specific_device_type
queries before filtering out the RETIRED devices.
Currently on production that's approx. 100,000 queries per
all_devices api call.
This patch also reduces the number of queries to the device_type
and test_job table for each device.

Change-Id: I9e1b54a088ae6173f337a0e4690484d952d57df7
parent ac8bb8e2
......@@ -265,11 +265,9 @@ class SchedulerAPI(ExposedAPI):
devices_list = []
for dev in Device.objects.all():
for dev in Device.objects.exclude(status=Device.RETIRED).select_related('current_job', 'device_type'):
if not dev.is_visible_to(self.user):
if dev.status == Device.RETIRED:
return [list((dev.hostname,, Device.STATUS_CHOICES[dev.status][1].lower(), if dev.current_job else None, dev.is_pipeline))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment