From 00afb41bc2ffc121ee3162a73a1f69217deb3d63 Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Thu, 30 Apr 2015 14:48:38 -0700 Subject: [PATCH] Update diversity tag to be a fixed 6 month window Use stackalytics start_date option along with setting release to all to collect data for the past 6 months. http://stackalytics.readthedocs.org/en/latest/userdoc/api_v1.0.html Update note at the bottom of the page to point to validate_tags now that it is in tree and used to apply the team:diverse-affiliation tag. Change-Id: Id60feb69704e0569873108a18a39e7787c7ab4eb --- reference/tags/team_diverse-affiliation.rst | 17 ++++---------- tools/diversity.py | 26 ++++++++++++++------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/reference/tags/team_diverse-affiliation.rst b/reference/tags/team_diverse-affiliation.rst index 4333af753..e0c8dd5a2 100644 --- a/reference/tags/team_diverse-affiliation.rst +++ b/reference/tags/team_diverse-affiliation.rst @@ -45,21 +45,13 @@ should represent >80% of any of the following: * the union of the memberships of the core review teams associated with the git repositories managed by the team -The timeline used for evaluation is aligned with the 6-month release cycle. The -current cycle's timeline should be used unless the cycle has not yet been longer -than 2 months, in which case the previous cycle should be used. This definition -is purely for convenience, as it makes it easy to check using existing tools -(stackalytics, in particular). +The timeline used for evaluation is based on the past 6 months, and should be +updated around the same time as the 6 month release. Based on how requirements are defined, this tag is only applicable for projects where their primary deliverables are represented by commits and reviews in git. An example of where this doesn't make sense is the release management team. -It would be better to use a fixed 6-month window for this. Once we come up with -a convenient way to evaluate this criteria against a fixed 6-month window, the -requirements can be changed. - - Tag application process ======================= @@ -96,5 +88,6 @@ all git repositories managed by a team. .. tagged-projects:: team:diverse-affiliation -A script used when checking the projects: -https://gist.github.com/russellb/cc89a390eefbb33e252b + +Script used to apply this tag: +http://git.openstack.org/cgit/openstack/governance/tree/tools/validate_tags.py diff --git a/tools/diversity.py b/tools/diversity.py index ce14bb142..4eb934db5 100755 --- a/tools/diversity.py +++ b/tools/diversity.py @@ -14,6 +14,7 @@ import os import sys +import time import requests import yaml @@ -22,20 +23,25 @@ import base s = requests.session() +six_months = int(time.time() - 30*6*24*60*60) # 6 months ago + def get_core_reviews_by_company(group): # reviews by individual reviews = s.get('http://stackalytics.com/api/' - '1.0/stats/engineers?metric=marks' - '&project_type=all&module=%s' % group).json() + '1.0/stats/engineers?metric=marks&release=all' + '&start_date=%s&project_type=all' + '&module=%s' % (six_months, group)).json() companies = {} 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' - % (group, eng['id'])).json()['stats'][0]['id'] + '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}) companies[company]['reviews'] += eng['metric'] companies[company]['reviewers'] += 1 @@ -46,12 +52,14 @@ def get_diversity(project): # commits by company group = "%s-group" % project.lower() commits = s.get('http://stackalytics.com/api/' - '1.0/stats/companies?metric=commits' - '&project_type=all&module=%s' % group).json() + '1.0/stats/companies?metric=commits&release=all' + '&project_type=all&module=%s&start_date=%s' + % (group, six_months)).json() # reviews by company reviews = s.get('http://stackalytics.com/api/' - '1.0/stats/companies?metric=marks' - '&project_type=all&module=%s' % group).json() + '1.0/stats/companies?metric=marks&release=all' + '&project_type=all&module=%s&start_date=%s' + % (group, six_months)).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