From 8984d97d20631c09b8b0188b0c47c8000f771ba0 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Wed, 23 Dec 2015 15:51:52 +0000 Subject: [PATCH] Fix --start with existing cache It turns out len(changes) is only the correct number of changes to skip the first time through with an empty cache. On subsequent runs it skips way too far ahead in the gerrit changes and thus never gets any new ones. This change keeps track of the number of new changes separately from the length of changes, which seems to make the behavior with a cache work correctly again. Change-Id: I1e3509d2d54b514afba64fedecc6a9f5ca408235 --- reviewstats/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reviewstats/utils.py b/reviewstats/utils.py index 3dea93f..e1e3b47 100644 --- a/reviewstats/utils.py +++ b/reviewstats/utils.py @@ -128,6 +128,7 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='', for project in projects: changes = {} + new_count = 0 logging.debug('Getting changes for project %s' % project['name']) if not only_open and not stable: @@ -182,8 +183,8 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='', cmd += ' status:open' if stable: cmd += ' branch:stable/%s' % stable - if len(changes): - cmd += ' --start %d' % len(changes) + if new_count: + cmd += ' --start %d' % new_count else: # Get a small set the first time so we can get to checking # againt the cache sooner @@ -219,6 +220,7 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='', changes[(new_change['id'], new_change['project'], new_change['branch'])] = new_change + new_count += 1 if end_of_changes: break