More gracefully handle intra-openstack moves

Splitting a project out into its own team causes problems with the
diversity check if the new project is inside of another project. This is
because there is no {project}-group stackalytics container, only a
{{project}} one.

Trap for the 404 error and re-point to {{project}} if {{project}}-group
is not found.

Change-Id: I68b1b7c4d98810f1d710351e4477fb83ef1fad21
This commit is contained in:
Monty Taylor 2017-03-21 08:23:46 -05:00
parent 28f210dc43
commit 295f7e581b
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594

View File

@ -125,10 +125,21 @@ def get_diversity_stats(project):
team_stats = {}
# commits by company
group = "%s-group" % project.lower()
commits = s.get('http://stackalytics.com/api/'
'1.0/stats/companies?metric=commits&release=all'
'&project_type=all&module=%s&start_date=%s'
% (group, six_months)).json()
commit_resp = s.get('http://stackalytics.com/api/'
'1.0/stats/companies?metric=commits&release=all'
'&project_type=all&module=%s&start_date=%s'
% (group, six_months))
if commit_resp.status_code == 404:
# The project in question doesn't have a group in stackalytics because
# it's part of a different group. Just look for it without the group
# suffix (e.g. during shade transition, there is no shade-group because
# the shade repo was in infra-group)
group = project.lower()
commit_resp = s.get('http://stackalytics.com/api/'
'1.0/stats/companies?metric=commits&release=all'
'&project_type=all&module=%s&start_date=%s'
% (group, six_months))
commits = commit_resp.json()
# reviews by company
reviews = s.get('http://stackalytics.com/api/'
'1.0/stats/companies?metric=marks&release=all'