data.queue: move name matching clause
This commit is contained in:
parent
26300d3c8e
commit
1f488acf12
1 changed files with 6 additions and 5 deletions
|
@ -52,12 +52,13 @@ class WorkQueue(object):
|
|||
|
||||
@classmethod
|
||||
def _available_jobs(cls, now, name_match_query):
|
||||
return cls._available_jobs_where(QueueItem.select(), now, name_match_query)
|
||||
return (cls
|
||||
._available_jobs_where(QueueItem.select(), now)
|
||||
.where(QueueItem.queue_name ** name_match_query))
|
||||
|
||||
@staticmethod
|
||||
def _available_jobs_where(query, now, name_match_query):
|
||||
return query.where(QueueItem.queue_name ** name_match_query,
|
||||
QueueItem.available_after <= now,
|
||||
def _available_jobs_where(query, now):
|
||||
return query.where(QueueItem.available_after <= now,
|
||||
((QueueItem.available == True) | (QueueItem.processing_expires <= now)),
|
||||
QueueItem.retries_remaining > 0)
|
||||
|
||||
|
@ -176,7 +177,7 @@ class WorkQueue(object):
|
|||
processing_expires=now + timedelta(seconds=processing_time),
|
||||
retries_remaining=QueueItem.retries_remaining-1)
|
||||
.where(QueueItem.id == db_item.id))
|
||||
changed_query = self._available_jobs_where(set_unavailable_query, now, name_match_query)
|
||||
changed_query = self._available_jobs_where(set_unavailable_query, now)
|
||||
changed = changed_query.execute()
|
||||
if changed == 1:
|
||||
item = AttrDict({
|
||||
|
|
Reference in a new issue