Optimize core list retrieval in reviewers

The list of core team members was being retrieved for every review
for each patchset. The utils.get_core_team does some caching to make
sure an API call wasn't made for each of these calls, but since the
project never changes for the review we can save a few cycles by not
making the call if it's not necessary.

This moves the retrieval of the core list before the loop through
reviews to make sure it's only called once per patchset.

Change-Id: Iac9f3b6eb71131eccce58a60656865eeb77b8fda
This commit is contained in:
Sean McGinnis 2016-01-17 12:51:47 -06:00
parent 5954bf284e
commit e33cf702a1

View File

@ -52,14 +52,14 @@ def process_patchset(project, patchset, reviewers, ts, options):
latest_core_pos_vote = 0
submitter = patchset['uploader'].get('username', 'unknown')
core_team = utils.get_core_team(project, options.server, options.user,
options.password)
for review in patchset.get('approvals', []):
if review['type'] != 'Code-Review':
# Only count code reviews. Don't add another for Approved, which
# is type 'Approved' or 'Workflow'
continue
core_team = utils.get_core_team(project, options.server, options.user,
options.password)
if review['by'].get('username', 'unknown') not in core_team:
# Only checking for disagreements from core team members
continue