Merge lp:~codehelp/lava-scheduler/1223264 into lp:lava-scheduler

Proposed by Neil Williams
Status: Merged
Approved by: Neil Williams
Approved revision: 266
Merged at revision: 266
Proposed branch: lp:~codehelp/lava-scheduler/1223264
Merge into: lp:lava-scheduler
Diff against target: 21 lines (+7/-2)
1 file modified
lava_scheduler_app/api.py (+7/-2)
To merge this branch: bzr merge lp:~codehelp/lava-scheduler/1223264
Reviewer Review Type Date Requested Status
Matthew Hart Approve
Review via email: mp+185473@code.launchpad.net

Description of the change

Fix the pending_devices XML query to check for null device_types in the results of the submitted jobs query.

To post a comment you must log in.
Revision history for this message
Matthew Hart (matthew-hart) wrote :

Nice and simple, I like it.

It's a shame we get None's from the filter but we need to deal with it so looks good, approve.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_scheduler_app/api.py'
2--- lava_scheduler_app/api.py 2013-09-02 15:14:15 +0000
3+++ lava_scheduler_app/api.py 2013-09-13 12:03:39 +0000
4@@ -200,10 +200,15 @@
5
6 pending_jobs_by_device = {}
7
8- jobs = TestJob.objects.filter(status=TestJob.SUBMITTED)\
9+ jobs_res = TestJob.objects.filter(status=TestJob.SUBMITTED)\
10 .values_list('requested_device_type_id')\
11 .annotate(pending_jobs=(Count('id')))
12- pending_jobs_by_device.update(dict(jobs))
13+ jobs = {}
14+ jobs_hash = dict(jobs_res)
15+ for job in jobs_hash:
16+ if job:
17+ jobs[job] = jobs_hash[job]
18+ pending_jobs_by_device.update(jobs)
19
20 # Get rest of the devices and put number of pending jobs as 0.
21 device_types = DeviceType.objects.values_list('name', flat=True)

Subscribers

People subscribed via source and target branches