Created
October 14, 2020 16:51
-
-
Save paulosman/6cc3a589d303422fdc82592c20b0bba8 to your computer and use it in GitHub Desktop.
github stats
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
import os | |
import datetime | |
import libhoney | |
from github import Github | |
g = Github(os.getenv('GH_ACCESS_TOKEN')) | |
libhoney.init( | |
writekey=os.getenv('HONEYCOMB_WRITE_KEY'), | |
dataset=os.getenv('HONEYCOMB_DATASET'), | |
api_host='https://api.honeycomb.io/', | |
debug=True, | |
) | |
org = g.get_organization('honeycombio') | |
# we just need something to group by, don't care about the format much | |
today = datetime.datetime.now().strftime("%m-%d-%Y") | |
for repo in org.get_repos(type='public'): | |
if repo.archived or repo.fork: | |
next | |
event = libhoney.new_event() | |
open_prs_count = repo.get_pulls(state='open').totalCount | |
commits = repo.get_commits() | |
last_commit_date = commits[0].commit.author.date.isoformat() | |
event.add({ | |
'date': today, | |
'repository_name': repo.name, | |
'repository_url': repo.html_url, | |
'open_issues': repo.open_issues_count, | |
'open_prs': open_prs_count, | |
'last_commit_date': last_commit_date, | |
}) | |
event.send() | |
libhoney.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment