Add diversity helper script
During the review of the team:diverse-affiliation tag, it was suggested that it might make sense to keep this script in this repo. It seems like as good of a place as any to collect things like this for now. The script produces the following output: <Team> (top commit % | top review % | top core review % | top core reviewer %) (top 2 commit % | top 2 review % | top 2 core review % | top 2 core reviewer %) Nova (19.61% | 19.85% | 25.50% | 31.25%) (36.92% | 34.00% | 47.39% | 56.25%) Swift (27.31% | 26.42% | 37.15% | 36.36%) (47.14% | 48.78% | 59.58% | 63.64%) Glance (23.37% | 29.19% | 39.84% | 33.33%) (36.68% | 47.41% | 62.52% | 58.33%) Keystone (42.62% | 29.91% | 46.61% | 37.50%) (54.81% | 41.88% | 64.86% | 56.25%) Horizon (27.97% | 16.94% | 22.53% | 30.77%) (42.59% | 31.51% | 41.70% | 46.15%) Neutron (26.50% | 19.63% | 24.44% | 16.67%) (40.45% | 32.32% | 42.55% | 33.33%) Cinder (11.73% | 11.33% | 16.68% | 20.00%) (21.87% | 22.26% | 30.87% | 30.00%) Ceilometer (52.33% | 31.96% | 63.04% | 50.00%) (65.56% | 63.32% | 79.50% | 70.00%) Heat (33.10% | 33.98% | 38.75% | 27.78%) (52.47% | 54.80% | 66.50% | 55.56%) Trove (35.16% | 38.89% | 47.22% | 42.86%) (57.99% | 66.54% | 79.69% | 71.43%) Ironic (26.79% | 28.23% | 31.09% | 33.33%) (42.35% | 51.86% | 60.67% | 58.33%) Oslo (31.18% | 28.08% | 34.42% | 23.08%) (51.22% | 49.79% | 55.98% | 35.90%) Infrastructure (39.10% | 49.58% | 48.20% | 40.91%) (50.04% | 66.44% | 70.49% | 56.82%) Documentation (19.68% | 26.75% | 35.92% | 19.05%) (32.38% | 44.08% | 51.56% | 33.33%) Quality Assurance (26.90% | 26.17% | 32.39% | 33.33%) (51.74% | 49.02% | 63.46% | 55.56%) TripleO (54.89% | 56.66% | 62.67% | 60.87%) (91.53% | 92.54% | 100.00% | 100.00%) Sahara (52.52% | 58.97% | 60.35% | 57.14%) (72.32% | 92.02% | 100.00% | 100.00%) Barbican (51.09% | 48.49% | 52.67% | 55.56%) (72.90% | 65.06% | 72.98% | 66.67%) Manila (47.77% | 30.60% | 44.93% | 50.00%) (64.95% | 59.10% | 75.52% | 75.00%) Zaqar (48.89% | 67.11% | 77.99% | 66.67%) (80.00% | 86.05% | 100.00% | 100.00%) Designate (56.50% | 64.63% | 65.49% | 60.00%) (80.08% | 97.14% | 100.00% | 100.00%) OpenStackClient (34.50% | 36.22% | 56.21% | 33.33%) (67.25% | 63.78% | 99.32% | 66.67%) Murano (85.14% | 91.99% | 99.33% | 87.50%) (93.24% | 95.15% | 100.00% | 100.00%) Magnum (32.10% | 35.80% | 36.81% | 28.57%) (49.63% | 52.01% | 55.58% | 42.86%) Change-Id: I59ac99452c9cdadccfb23ee27539343f3319b2dd
This commit is contained in:
parent
f9ccd75f92
commit
0ebb407899
125
tools/diversity.py
Executable file
125
tools/diversity.py
Executable file
@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
# TODO: Automate this from projects.yaml, instead.
|
||||
GROUPS = (
|
||||
('Nova', 'nova-group'),
|
||||
('Swift', 'swift-group'),
|
||||
('Glance', 'glance-group'),
|
||||
('Keystone', 'keystone-group'),
|
||||
('Horizon', 'horizon-group'),
|
||||
('Neutron', 'neutron-group'),
|
||||
('Cinder', 'cinder-group'),
|
||||
('Ceilometer', 'ceilometer-group'),
|
||||
('Heat', 'heat-group'),
|
||||
('Trove', 'trove-group'),
|
||||
('Ironic', 'ironic-group'),
|
||||
('Oslo', 'oslo-group'),
|
||||
('Infrastructure', 'infra-group'),
|
||||
('Documentation', 'documentation-group'),
|
||||
('Quality Assurance', 'qa-group'),
|
||||
('TripleO', 'tripleo-group'),
|
||||
('Sahara', 'sahara-group'),
|
||||
('Barbican', 'barbican-group'),
|
||||
('Manila', 'manila-group'),
|
||||
('Zaqar', 'zaqar-group'),
|
||||
('Designate', 'designate-group'),
|
||||
('OpenStackClient', 'python-openstackclient'),
|
||||
('Murano', 'murano-group'),
|
||||
('Magnum', 'magnum'),
|
||||
)
|
||||
|
||||
|
||||
def get_core_reviews_by_company(group):
|
||||
# reviews by individual
|
||||
reviews = requests.get('http://stackalytics.com/api/'
|
||||
'1.0/stats/engineers?metric=marks'
|
||||
'&project_type=all&module=%s' % group).json()
|
||||
companies = {}
|
||||
for eng in reviews['stats']:
|
||||
if eng['core'] != 'master':
|
||||
continue
|
||||
company = requests.get('http://stackalytics.com/api/1.0/'
|
||||
'stats/companies?metric=marks&'
|
||||
'module=%s&user_id=%s&project_type=all'
|
||||
% (group, eng['id'])).json()['stats'][0]['id']
|
||||
companies.setdefault(company, {'reviewers': 0, 'reviews': 0})
|
||||
companies[company]['reviews'] += eng['metric']
|
||||
companies[company]['reviewers'] += 1
|
||||
return companies
|
||||
|
||||
|
||||
def get_diversity(project, group):
|
||||
# commits by company
|
||||
commits = requests.get('http://stackalytics.com/api/'
|
||||
'1.0/stats/companies?metric=commits'
|
||||
'&project_type=all&module=%s' % group).json()
|
||||
# reviews by company
|
||||
reviews = requests.get('http://stackalytics.com/api/'
|
||||
'1.0/stats/companies?metric=marks'
|
||||
'&project_type=all&module=%s' % group).json()
|
||||
core_reviews_by_company = get_core_reviews_by_company(group)
|
||||
commits_total = sum([company['metric'] for company in commits['stats']])
|
||||
commits_top = float(commits['stats'][0]['metric']) / commits_total * 100
|
||||
commits_top2 = ((float(commits['stats'][0]['metric']) +
|
||||
float(commits['stats'][1]['metric']))
|
||||
/ commits_total * 100)
|
||||
reviews_total = sum([company['metric'] for company in reviews['stats']])
|
||||
reviews_top = float(reviews['stats'][0]['metric']) / reviews_total * 100
|
||||
reviews_top2 = ((float(reviews['stats'][0]['metric']) +
|
||||
float(reviews['stats'][1]['metric']))
|
||||
/ reviews_total * 100)
|
||||
core_review_values = [company['reviews'] for company in
|
||||
core_reviews_by_company.itervalues()]
|
||||
core_review_values.sort(reverse=True)
|
||||
core_reviews_total = sum(core_review_values)
|
||||
core_reviews_top = (float(core_review_values[0]) /
|
||||
core_reviews_total * 100)
|
||||
core_reviews_top2 = ((float(core_review_values[0]) +
|
||||
float(core_review_values[1])) /
|
||||
core_reviews_total * 100)
|
||||
core_reviewers_values = [company['reviewers'] for company in
|
||||
core_reviews_by_company.itervalues()]
|
||||
core_reviewers_values.sort(reverse=True)
|
||||
core_reviewers_total = sum(core_reviewers_values)
|
||||
core_reviewers_top = (float(core_reviewers_values[0]) /
|
||||
core_reviewers_total * 100)
|
||||
core_reviewers_top2 = ((float(core_reviewers_values[0]) +
|
||||
float(core_reviewers_values[1])) /
|
||||
core_reviewers_total * 100)
|
||||
print '%-18s (%.2f%% | %.2f%% | %.2f%% | %.2f%%)' % (
|
||||
project, commits_top, reviews_top, core_reviews_top,
|
||||
core_reviewers_top)
|
||||
print '%-18s (%.2f%% | %.2f%% | %.2f%% | %.2f%%)' % (
|
||||
'', commits_top2, reviews_top2, core_reviews_top2,
|
||||
core_reviewers_top2)
|
||||
|
||||
|
||||
def main():
|
||||
print '<Team> (top commit % | top review % | top core review % | ' \
|
||||
'top core reviewer %)'
|
||||
print ' (top 2 commit % | top 2 review % | top 2 core review % | ' \
|
||||
'top 2 core reviewer %)'
|
||||
for project, group in GROUPS:
|
||||
get_diversity(project, group)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Loading…
x
Reference in New Issue
Block a user