Skip to content

Instantly share code, notes, and snippets.

@tinoji
Last active October 5, 2021 17:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tinoji/b335a3d68a83805320fbed8320a8c541 to your computer and use it in GitHub Desktop.
Save tinoji/b335a3d68a83805320fbed8320a8c541 to your computer and use it in GitHub Desktop.
Plot commit activity of a GitHub organization in last year
import isoweek
import datetime
import matplotlib.pyplot as plt
from github import Github
from operator import add
g = Github("{user}", "{password}")
# For GitHub Enterprise
# g = Github(base_url="https://{hostname}/api/v3", login_or_token="{access_token}")
weeks = isoweek.Week.last_week_of_year(datetime.datetime.now().year - 1).week
stat = [0] * weeks
for repo in g.get_organization("{organization}").get_repos():
activity = repo.get_stats_commit_activity()
if activity is not None:
activity_per_week = [x.total for x in activity]
stats = list(map(add, stat, activity_per_week))
x = list(range(weeks))
plt.bar(x, stats, width=1.0)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment