Show how many patch sets were created

When generating the reviewers report, also include how many new patch
sets were submitted during this time frame.

Change-Id: I944022c6c9c40e091bbf4557643b50d89d5d63f7
This commit is contained in:
Russell Bryant 2013-11-12 05:03:52 -05:00
parent 69b6423890
commit 51c2e42c4a
3 changed files with 30 additions and 21 deletions

View File

@ -33,23 +33,6 @@ def sec_to_period_string(seconds):
return '%d days, %d hours, %d minutes' % (days, hours, minutes)
def get_age_of_patch(patch, now_ts):
approvals = patch.get('approvals', [])
approvals.sort(key=lambda a: a['grantedOn'])
# The createdOn timestamp on the patch isn't what we want.
# It's when the patch was written, not submitted for review.
# The next best thing in the data we have is the time of the
# first review. When all is working well, jenkins or smokestack
# will comment within the first hour or two, so that's better
# than the other timestamp, which may reflect that the code
# was written many weeks ago, even though it was just recently
# submitted for review.
if approvals:
return now_ts - approvals[0]['grantedOn']
else:
return now_ts - patch['createdOn']
def average_age(changes, key='age'):
if not changes:
return 0
@ -335,10 +318,10 @@ def main(argv=None):
waiting_for_review = False
break
change['age'] = get_age_of_patch(latest_patch, now_ts)
change['age2'] = get_age_of_patch(change['patchSets'][0], now_ts)
change['age'] = utils.get_age_of_patch(latest_patch, now_ts)
change['age2'] = utils.get_age_of_patch(change['patchSets'][0], now_ts)
patch = find_oldest_no_nack(change)
change['age3'] = get_age_of_patch(patch, now_ts) if patch else 0
change['age3'] = utils.get_age_of_patch(patch, now_ts) if patch else 0
if waiting_for_review:
waiting_on_reviewer.append(change)

View File

@ -145,14 +145,21 @@ def main(argv=None):
reviewers = {}
cut_off = datetime.datetime.now() - datetime.timedelta(days=options.days)
now = datetime.datetime.utcnow()
cut_off = now - datetime.timedelta(days=options.days)
ts = calendar.timegm(cut_off.timetuple())
now_ts = calendar.timegm(now.timetuple())
patches_created = 0
for project in projects:
changes = utils.get_changes([project], options.user, options.key)
for change in changes:
for patchset in change.get('patchSets', []):
process_patchset(project, patchset, reviewers, ts)
age = utils.get_age_of_patch(patchset, now_ts)
if (now_ts - age) > ts:
patches_created += 1
reviewers = [(v, k) for k, v in reviewers.iteritems()
if k.lower() not in ('jenkins', 'smokestack')]
@ -215,6 +222,8 @@ def main(argv=None):
file_obj.write('Total reviewers: %d\n' % len(reviewers))
file_obj.write('Total reviews by core team: %d\n' % core_total)
file_obj.write('Core team size: %d\n' % len(project['core-team']))
file_obj.write('New patch sets in the last %d days: %d\n' % (
options.days, patches_created))
file_obj.write(
'\n(*) Disagreements are defined as a +1 or +2 vote on a ' \
'patch where a core team member later gave a -1 or -2 vote' \

View File

@ -112,3 +112,20 @@ def patch_set_approved(patch_set):
if review['type'] == 'APRV':
return True
return False
def get_age_of_patch(patch, now_ts):
approvals = patch.get('approvals', [])
approvals.sort(key=lambda a: a['grantedOn'])
# The createdOn timestamp on the patch isn't what we want.
# It's when the patch was written, not submitted for review.
# The next best thing in the data we have is the time of the
# first review. When all is working well, jenkins or smokestack
# will comment within the first hour or two, so that's better
# than the other timestamp, which may reflect that the code
# was written many weeks ago, even though it was just recently
# submitted for review.
if approvals:
return now_ts - approvals[0]['grantedOn']
else:
return now_ts - patch['createdOn']