From e33cf702a104a8e83bc3174ec755e1980b121ffd Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sun, 17 Jan 2016 12:51:47 -0600 Subject: [PATCH] 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 --- reviewstats/cmd/reviewers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reviewstats/cmd/reviewers.py b/reviewstats/cmd/reviewers.py index 411ce43..96dbfe1 100755 --- a/reviewstats/cmd/reviewers.py +++ b/reviewstats/cmd/reviewers.py @@ -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