Commit b7254aec authored by Rémi Duraffort's avatar Rémi Duraffort
Browse files

XMLRPC-API: decrease the number of sql requests



Use select_related when listing devices and jobs.
Signed-off-by: default avatarRémi Duraffort <remi.duraffort@linaro.org>
parent e65cfdc0
......@@ -232,9 +232,9 @@ class SchedulerDevicesAPI(ExposedV2API):
This function returns an XML-RPC array in which each item is a
dictionary with device information
"""
devices = Device.objects.all()
devices = Device.objects.all().select_related("device_type")
if not show_all:
devices = Device.objects.exclude(health=Device.HEALTH_RETIRED)
devices = devices.exclude(health=Device.HEALTH_RETIRED)
devices = devices.order_by("hostname")
ret = []
......
......@@ -191,7 +191,9 @@ class SchedulerJobsAPI(ExposedV2API):
ret = []
start = max(0, start)
limit = min(limit, 100)
jobs = TestJob.objects.all()
jobs = TestJob.objects.all().select_related(
"requested_device_type", "submitter"
)
if state:
try:
jobs = jobs.filter(state=TestJob.STATE_REVERSE[state.capitalize()])
......
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