[Branch,~linaro-validation/lava-scheduler/trunk] Rev 266: Neil Williams 2013-09-13 Fix 1223264 to check for empty device_types in

Message ID 20130916101533.14738.36587.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Neil Williams Sept. 16, 2013, 10:15 a.m.
Merge authors:
  Neil Williams (codehelp)
Related merge proposals:
  https://code.launchpad.net/~codehelp/lava-scheduler/1223264/+merge/185473
  proposed by: Neil Williams (codehelp)
  review: Approve - Matthew Hart (matthew-hart)
------------------------------------------------------------
revno: 266 [merge]
committer: Neil Williams <neil.williams@linaro.org>
branch nick: lava-scheduler
timestamp: Mon 2013-09-16 10:55:47 +0100
message:
  Neil Williams 2013-09-13 Fix 1223264 to check for empty device_types in
   the pending_jobs_submitted query results.
modified:
  lava_scheduler_app/api.py


--
lp:lava-scheduler
https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk

You are subscribed to branch lp:lava-scheduler.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription

Patch

=== modified file 'lava_scheduler_app/api.py'
--- lava_scheduler_app/api.py	2013-09-02 15:14:15 +0000
+++ lava_scheduler_app/api.py	2013-09-13 11:39:18 +0000
@@ -200,10 +200,15 @@ 
 
         pending_jobs_by_device = {}
 
-        jobs = TestJob.objects.filter(status=TestJob.SUBMITTED)\
+        jobs_res = TestJob.objects.filter(status=TestJob.SUBMITTED)\
             .values_list('requested_device_type_id')\
             .annotate(pending_jobs=(Count('id')))
-        pending_jobs_by_device.update(dict(jobs))
+        jobs = {}
+        jobs_hash = dict(jobs_res)
+        for job in jobs_hash:
+            if job:
+                jobs[job] = jobs_hash[job]
+        pending_jobs_by_device.update(jobs)
 
         # Get rest of the devices and put number of pending jobs as 0.
         device_types = DeviceType.objects.values_list('name', flat=True)