diff mbox

[Branch,~linaro-validation/lava-scheduler/trunk] Rev 112: make the device tagging code work with postgres

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

Commit Message

Michael-Doyle Hudson Jan. 16, 2012, 11:28 p.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 112 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Tue 2012-01-17 12:26:44 +1300
message:
  make the device tagging code work with postgres
modified:
  lava_scheduler_daemon/dbjobsource.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
diff mbox

Patch

=== modified file 'lava_scheduler_daemon/dbjobsource.py'
--- lava_scheduler_daemon/dbjobsource.py	2011-12-15 03:06:49 +0000
+++ lava_scheduler_daemon/dbjobsource.py	2012-01-16 23:13:54 +0000
@@ -89,15 +89,17 @@ 
             jobs_for_device = jobs_for_device.extra(
                 select={
                     'is_targeted': 'requested_device_id is not NULL',
-                    'missing_tags': '''
-                        select count(*) from lava_scheduler_app_testjob_tags
-                                       where testjob_id = lava_scheduler_app_testjob.id
-                                       and tag_id not in (select tag_id
-                                                            from lava_scheduler_app_device_tags
-                                                           where device_id = '%s')
-                        ''' % device.hostname,
                     },
-                where=['missing_tags = 0'],
+                where=[
+                    # In human language, this is saying "where the number of
+                    # tags that are on the job but not on the device is 0"
+                    '''(select count(*) from lava_scheduler_app_testjob_tags
+                         where testjob_id = lava_scheduler_app_testjob.id
+                           and tag_id not in (select tag_id
+                                                from lava_scheduler_app_device_tags
+                                               where device_id = '%s')) = 0'''
+                    % device.hostname,
+                    ],
                 order_by=['-is_targeted', 'submit_time'])
             jobs = jobs_for_device[:1]
             if jobs: