From ef63f7e139cbd1aea43e3ac59e2cbe3395dd29cc Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 10 Dec 2019 16:31:54 +0000 Subject: [PATCH] Include aggregate change revisions in owner data In order to make some calculations around revision-per-change rates, add a revision count for merged changes alongside the existing merged change count. This is data we already get from the Gerrit API, so it shouldn't impact performance, and it doesn't alter any existing fields in the output (only adds a new one). Change-Id: I2e3129efc5cd96e5c93815b6d0e699f04a838bef --- openstack_election/owners.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openstack_election/owners.py b/openstack_election/owners.py index 9118d480..99aad98d 100644 --- a/openstack_election/owners.py +++ b/openstack_election/owners.py @@ -318,6 +318,10 @@ def main(options): # The change number, for ease of tracking number = change['_number'] + # How many revisions this change had before merging + revisions = list( + change['revisions'].values())[0]['_number'] + # We index owners by their unique Gerrit # account Id numbers owner = change['owner']['_account_id'] @@ -375,6 +379,7 @@ def main(options): 'newest_id': number, 'oldest': merged, 'oldest_id': number, + 'revisions': revisions, 'username': change['owner'].get('username'), } @@ -384,6 +389,7 @@ def main(options): # dates else: owners[owner]['count'] += 1 + owners[owner]['revisions'] += revisions if merged > owners[owner]['newest']: owners[owner]['newest'] = merged owners[owner]['newest_id'] = number @@ -441,6 +447,7 @@ def main(options): # update newest/oldest dates if owner in projects[project]: projects[project][owner]['count'] += 1 + projects[project][owner]['revisions'] += revisions if merged > projects[project][owner]['newest']: projects[project][owner]['newest'] = merged projects[project][owner]['newest_id'] = number @@ -458,6 +465,7 @@ def main(options): 'newest_id': number, 'oldest': merged, 'oldest_id': number, + 'revisions': revisions, } # The negative counter will be used as a makeshift account Id @@ -497,6 +505,7 @@ def main(options): 'oldest': stamp, 'oldest_id': 0, 'preferred': address, + 'revisions': -1, 'username': '_non_code_contributor', } if owner not in projects[project]: @@ -506,6 +515,7 @@ def main(options): 'newest_id': 0, 'oldest': stamp, 'oldest_id': 0, + 'revisions': -1, } counter += 1 @@ -619,7 +629,8 @@ def main(options): # merged dates with the team-specific value rather than # using the count from the global set for field in ( - 'count', 'newest', 'newest_id', 'oldest', 'oldest_id'): + 'count', 'newest', 'newest_id', 'oldest', 'oldest_id', + 'revisions'): output[owner][field] = projects[project][owner][field] # Append preferred member addresses to the PTL electoral rolls