change logic for filtering queued, running and finished jobs in AFE to consider parsing jobs as running instead of queued.
Signed-off-by: Steve Howard <showard@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3779 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index 40f9639..ae966f9 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -91,22 +91,25 @@
Generate a SQL WHERE clause for job status filtering, and return it in
a dict of keyword args to pass to query.extra(). No more than one of
the parameters should be passed as True.
+ * not_yet_run: all HQEs are Queued
+ * finished: all HQEs are complete
+ * running: everything else
"""
assert not ((not_yet_run and running) or
(not_yet_run and finished) or
(running and finished)), ('Cannot specify more than one '
'filter to this function')
+
+ not_queued = ('(SELECT job_id FROM host_queue_entries WHERE status != "%s")'
+ % models.HostQueueEntry.Status.QUEUED)
+ not_finished = '(SELECT job_id FROM host_queue_entries WHERE not complete)'
+
if not_yet_run:
- where = ['id NOT IN (SELECT job_id FROM host_queue_entries '
- 'WHERE active OR complete)']
+ where = ['id NOT IN ' + not_queued]
elif running:
- where = ['(id IN (SELECT job_id FROM host_queue_entries '
- 'WHERE active OR complete)) AND '
- '(id IN (SELECT job_id FROM host_queue_entries '
- 'WHERE not complete OR active))']
+ where = ['(id IN %s) AND (id IN %s)' % (not_queued, not_finished)]
elif finished:
- where = ['id NOT IN (SELECT job_id FROM host_queue_entries '
- 'WHERE not complete OR active)']
+ where = ['id NOT IN ' + not_finished]
else:
return {}
return {'where': where}