diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-10-16 13:09:31 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-10-16 13:09:31 -0400 |
commit | 1d54a8c8a09eacdc2ed1213afaa8639b7393b6ef (patch) | |
tree | 77c6801b5e17bd120de749763b5365d409f90223 | |
parent | 43b147ab65df7869f4dc91f2193ca91592ff4532 (diff) | |
download | korg-helpers-1d54a8c8a09eacdc2ed1213afaa8639b7393b6ef.tar.gz |
Improve autoarchive housekeeping
We stopped auto-archiving as soon as we came across a page containing
patches past the cutoff date. However, for projects with a handful of
patches this meant that the entire page needed to fill up before we
auto-archived any eligible patches. This change goes through all patches
on the page before stopping.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | git-patchwork-bot.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/git-patchwork-bot.py b/git-patchwork-bot.py index b357c1b..561146c 100755 --- a/git-patchwork-bot.py +++ b/git-patchwork-bot.py @@ -52,7 +52,7 @@ DB_VERSION = 1 REST_API_VERSION = '1.1' HUNK_RE = re.compile(r'^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@') FILENAME_RE = re.compile(r'^(---|\+\+\+) (\S+)') -REST_PER_PAGE = 50 +REST_PER_PAGE = 100 CONFIG = None @@ -937,8 +937,12 @@ def housekeeping(pname): page = 0 seen = set() pagedata = list() + lastpage = False + archived = 0 while True: - if not pagedata: + if not pagedata and not lastpage: + if archived: + logger.info('Archived %d patches, grabbing next page', archived) params = [ ('project', project_id), ('archived', 'false'), @@ -964,8 +968,9 @@ def housekeeping(pname): # Did we go too far forward? patch_date = datetime.datetime.strptime(entry.get('date'), "%Y-%m-%dT%H:%M:%S") if patch_date >= cutoffdate: - logger.debug('Reached the cutoff date, stopping at %s', patch_date) - break + # mark that we're on the last page + lastpage = True + continue patch_id = entry.get('id') if patch_id in seen: @@ -975,14 +980,16 @@ def housekeeping(pname): logger.info('Setting to archived is not working, exiting loop.') break - seen.update([patch_id]) - patch_title = entry.get('name') - logger.info('Archiving: %s', patch_title) + seen.add(patch_id) + archived += 1 if not DRYRUN: rm.update_patch(patch_id, archived=True) else: logger.info(' Dryrun: Not actually archiving') + if archived: + logger.info('Archived %d total patches', archived) + if not report: return |