From aca45f3054939cd2183057eb6c53bb2c93cfa670 Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Thu, 19 Jan 2017 01:12:34 +0200 Subject: [PATCH] Use all stats while calculating reviews by company While obtaining stats for particilar core reviewer teamstats script ignores the case when person changes company. In this case, "stats" data in responce obj includes more than one stat, but only first one is taken now. This patch fixes this issue. Change-Id: I3a588c0fc742b3e123eb32623315fdf2894ce7c9 --- tools/teamstats.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/teamstats.py b/tools/teamstats.py index ca4a7f26d..87a3ff224 100644 --- a/tools/teamstats.py +++ b/tools/teamstats.py @@ -102,17 +102,16 @@ def get_core_reviews_by_company(group): for eng in reviews['stats']: if eng['core'] != 'master': continue - company = s.get('http://stackalytics.com/api/1.0/' - 'stats/companies?metric=marks&' - 'module=%s&user_id=%s&project_type=all' - '&release=all&start_date=%s' - % (group, eng['id'], - six_months)).json()['stats'][0]['id'] - companies.setdefault(company, {'reviewers': 0, 'reviews': 0}) + for stat in s.get('http://stackalytics.com/api/1.0/stats/' + 'companies?metric=marks&module=%s&user_id=%s&' + 'project_type=all&release=all&start_date=%s' % + (group, eng['id'], six_months)).json()['stats']: + company = stat['id'] + companies.setdefault(company, {'reviewers': 0, 'reviews': 0}) - if eng['metric'] >= MIN_REVIEWS or eng['metric'] >= min_percent: - companies[company]['reviews'] += eng['metric'] - companies[company]['reviewers'] += 1 + if eng['metric'] >= MIN_REVIEWS or eng['metric'] >= min_percent: + companies[company]['reviews'] += stat['metric'] + companies[company]['reviewers'] += 1 return companies