Skip to content

Instantly share code, notes, and snippets.

@hvelarde
Last active December 27, 2017 12:40
Show Gist options
  • Save hvelarde/8322843 to your computer and use it in GitHub Desktop.
Save hvelarde/8322843 to your computer and use it in GitHub Desktop.
Getting your contributions on a GitHub organization using github3.py to access the GitHub API.
>>> user, password = 'hvelarde', 'password'
>>> from github3 import login
>>> g = login(user, password=password)
>>> o = g.organization('collective')
>>> g.ratelimit_remaining
3369
>>> my_stats = []
>>> for r in o.iter_repos():
... for c in r.iter_contributor_statistics():
... if user in repr(c.author):
... my_stats.append((r.name, c.total))
...
>>> g.ratelimit_remaining
2198
>>> len(my_stats)
74
>>> sum([total for repo, total in my_stats])
2975
>>> import operator
>>> my_stats = sorted(my_stats, key=operator.itemgetter(1), reverse=True)
>>> from pprint import pprint
>>> pprint(my_stats)
[(u'collective.cover', 607),
(u'collective.nitf', 456),
(u'collective.polls', 221),
(u'collective.z3cform.widgets', 175),
(u'collective.upload', 139),
(u'collective.newsflash', 97),
(u'collective.elections', 95),
(u'collective.syndication', 84),
(u'collective.weather', 78),
(u'collective.prettydate', 65),
(u'collective.disqus', 62),
(u'collective.newsticker', 59),
(u'collective.behavior.localdiazo', 58),
(u'sc.social.like', 53),
(u'sc.contentrules.groupbydate', 46),
(u'collective.facebook.portlets', 43),
(u'buildout.plonetest', 43),
(u'collective.googlenews', 40),
(u'collective.github.com', 39),
(u'collective.aviary', 33),
(u'collective.facebook.accounts', 32),
(u'collective.twitter.portlets', 31),
(u'collective.portlet.twitter', 26),
(u'Products.ImageEditor', 22),
(u'collective.portlet.calendar', 22),
(u'Products.PloneKeywordManager', 21),
(u'collective.behavior.localregistry', 19),
(u'collective.twitter.accounts', 18),
(u'collective.googleanalytics', 18),
(u'plone.app.imagecropping', 18),
(u'collective.developermanual', 14),
(u'Products.windowZ', 13),
(u'Products.ATGoogleVideo', 13),
(u'ploneawards.contenttypes', 12),
(u'Solgema.fullcalendar', 11),
(u'collective.z3cform.datetimewidget', 10),
(u'Products.EasyNewsletter', 10),
(u'collective.documentviewer', 10),
(u'collective.addthis', 9),
(u'collective.z3cform.datagridfield', 9),
(u'collective.portlet.usertrack', 9),
(u'ploneawards.buildout', 9),
(u'qi.portlet.TagClouds', 8),
(u'collective.lineage', 7),
(u'collective.portlet.pythonscript', 7),
(u'collective.themecustomizer', 7),
(u'collective.routes', 6),
(u'Products.Faq', 6),
(u'dexterity.membrane', 6),
(u'collective.recipe.cmd', 6),
(u'cioppino.twothumbs', 5),
(u'collective.facebook.wall', 5),
(u'templer.core', 5),
(u'collective.recipe.omelette', 5),
(u'example.conference', 4),
(u'collective.formwidget.relationfield', 4),
(u'templer.buildout', 4),
(u'i18ndude', 4),
(u'ploneawards.theme', 4),
(u'ploneawards.policy', 4),
(u'collective.oembed', 3),
(u'collective.twitter.search', 3),
(u'templer.plone', 3),
(u'collective.blog.star', 3),
(u'collective.easytemplate', 3),
(u'collective.timedevents', 3),
(u'collective.stats', 2),
(u'collective.recipe.plonesite', 2),
(u'collective.portlet.relateditems', 2),
(u'templer.plonebuildout', 1),
(u'templer.zope', 1),
(u'templer.silva', 1),
(u'collective.panels', 1),
(u'collective.portlet.tal', 1)]
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment