Update for Gerrit 2.8

Some of the review types returned in the Gerrit JSON data have
changed, so reviewstats wasn't finding any reviews.  This also
adds support for the new Workflow votes so new approvals will
show up correctly.

Note that the output from reviewstats still seems to be rather
bogus because the review timestamps appear to have all been updated
in the upgrade, but I think reviewstats is processing the data as
intended with this change.

Change-Id: I6cccf427a0ff875fdbc59f8c8d83a37db567f786
This commit is contained in:
Ben Nemec 2014-04-29 20:54:57 +00:00
parent 098adb8279
commit d6ec27547f
2 changed files with 8 additions and 6 deletions

View File

@ -54,9 +54,9 @@ def process_patchset(project, patchset, reviewers, ts):
submitter = patchset['uploader'].get('username', 'unknown')
for review in patchset.get('approvals', []):
if review['type'] != 'CRVW':
if review['type'] != 'Code-Review':
# Only count code reviews. Don't add another for Approved, which
# is type 'APRV'
# is type 'Approved' or 'Workflow'
continue
if review['by'].get('username', 'unknown') not in project['core-team']:
# Only checking for disagreements from core team members
@ -72,16 +72,17 @@ def process_patchset(project, patchset, reviewers, ts):
if review['grantedOn'] < ts:
continue
if review['type'] not in ('CRVW', 'APRV'):
if review['type'] not in ('Code-Review', 'Approved', 'Workflow'):
continue
reviewer = review['by'].get('username', 'unknown')
set_defaults(reviewer, reviewers)
if review['type'] == 'APRV':
if (review['type'] == 'Approved' or
(review['type'] == 'Workflow' and int(review['value']) > 0)):
cur = reviewers[reviewer]['votes']['A']
reviewers[reviewer]['votes']['A'] = cur + 1
else:
elif review['type'] != 'Workflow':
cur_total = reviewers[reviewer].get('total', 0)
reviewers[reviewer]['total'] = cur_total + 1
set_defaults(submitter, reviewers)

View File

@ -197,7 +197,8 @@ def patch_set_approved(patch_set):
"""
approvals = patch_set.get('approvals', [])
for review in approvals:
if review['type'] == 'APRV':
if (review['type'] == 'Approved' or
(review['type'] == 'Workflow' and int(review['value']) > 0)):
return True
return False