Last active
December 11, 2015 22:08
-
-
Save rlr/4667150 to your computer and use it in GitHub Desktop.
Get webdev contributors, # of contributions and contributed repos as a CSV.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requirements: | |
# pip install requests==1.1.0 | |
import requests | |
repos = [ | |
'bedrock', | |
'django-browserid', | |
'input.mozilla.org', | |
'fjord', | |
'kitsune', | |
'kuma', | |
'mozillians', | |
'remo', | |
'socorro', | |
'zamboni',] | |
commit_levels = [100, 50, 25, 10] | |
base_url = "https://api.github.com/repos/mozilla" | |
contributors = {} | |
contributors_by_level = {} | |
# Figure out the # of contributions per contributor: | |
for repo in repos: | |
url = '%s/%s/contributors' % (base_url, repo) | |
for repocontributor in requests.get(url).json(): | |
username = repocontributor['login'] | |
contributions = repocontributor['contributions'] | |
contributor = contributors.setdefault(username, {}) | |
contributor['contributions'] = ( | |
contributor.get('contributions', 0) + contributions) | |
contributor.setdefault('repos', []).append(repo) | |
# Group the contributors into levels by # of contributions: | |
for user, contributor in contributors.items(): | |
contributions = contributor['contributions'] | |
for level in commit_levels: | |
if contributions >= level: | |
contributors_by_level.setdefault(level, []).append(user) | |
break | |
def print_contributors(): | |
for user, contributor in contributors.items(): | |
print '%s, %s, %s' % ( | |
user, contributor['contributions'], ' '.join(contributor['repos'])) | |
def print_contributors_by_level(): | |
for level in commit_levels: | |
print '========== %s+ ==========' % level | |
for user in contributors_by_level[level]: | |
print user | |
print_contributors_by_level() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment