Add configurable limits for number of builds allowed under a namespace
We also support that limit being increased automatically once a successful billing charge has gone through
This commit is contained in:
parent
62971b7f20
commit
9a452ace11
10 changed files with 125 additions and 33 deletions
|
@ -74,6 +74,19 @@ class WorkQueue(object):
|
|||
._available_jobs(now, name_match_query)
|
||||
.where(~(QueueItem.queue_name << running_query)))
|
||||
|
||||
def num_available_jobs(self, canonical_name_list):
|
||||
"""
|
||||
Returns the number of available queue items with a given prefix.
|
||||
"""
|
||||
def strip_slash(name):
|
||||
return name.lstrip('/')
|
||||
canonical_name_list = map(strip_slash, canonical_name_list)
|
||||
|
||||
available = self._available_jobs(datetime.utcnow(),
|
||||
'/'.join([self._queue_name] + canonical_name_list) + '%')
|
||||
|
||||
return available.count()
|
||||
|
||||
def num_available_jobs_between(self, available_min_time, available_max_time, canonical_name_list):
|
||||
"""
|
||||
Returns the number of available queue items with a given prefix, between the two provided times.
|
||||
|
|
Reference in a new issue