PR changes in response to comments
This commit is contained in:
parent
c767aafcd6
commit
8ed8367404
1 changed files with 14 additions and 6 deletions
|
@ -2778,11 +2778,19 @@ def cancel_repository_build(build, work_queue):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_repository_events(repository, time_delta, time_delta_earlier, clause):
|
def _get_repository_events(repository, time_delta, time_delta_earlier, clause):
|
||||||
|
""" Returns a pair representing the count of the number of events for the given
|
||||||
|
repository in each of the specified time deltas. The date ranges are calculated by
|
||||||
|
taking the current time today and subtracting the time delta given. Since
|
||||||
|
we want to grab *two* ranges, we restrict the second range to be greater
|
||||||
|
than the first (i.e. referring to an earlier time), so we can conduct the
|
||||||
|
lookup in a single query. The clause is used to further filter the kind of
|
||||||
|
events being found.
|
||||||
|
"""
|
||||||
since = date.today() - time_delta
|
since = date.today() - time_delta
|
||||||
since_earlier = date.today() - time_delta_earlier
|
since_earlier = date.today() - time_delta_earlier
|
||||||
|
|
||||||
if since_earlier >= since:
|
if since_earlier >= since:
|
||||||
raise Exception('time_delta_earlier must be greater than time_delta')
|
raise ValueError('time_delta_earlier must be greater than time_delta')
|
||||||
|
|
||||||
# This uses a CASE WHEN inner clause to further filter the count.
|
# This uses a CASE WHEN inner clause to further filter the count.
|
||||||
formatted = since.strftime('%Y-%m-%d')
|
formatted = since.strftime('%Y-%m-%d')
|
||||||
|
|
Reference in a new issue