Last active
October 5, 2021 17:59
-
-
Save tinoji/b335a3d68a83805320fbed8320a8c541 to your computer and use it in GitHub Desktop.
Plot commit activity of a GitHub organization in last year
This file contains 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
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