Skip to content

Instantly share code, notes, and snippets.

@jonashaag
Created October 10, 2020 20:36
Show Gist options
  • Save jonashaag/89f147be036ce85109db003acff2ba90 to your computer and use it in GitHub Desktop.
Save jonashaag/89f147be036ce85109db003acff2ba90 to your computer and use it in GitHub Desktop.
List of GitHub projects you have been involved in
import json
import os
import requests
from collections import Counter
username = "jonashaag"
password = "..."
cache_name = f"involves-{username}.json"
if not os.path.exists(cache_name):
items = []
page = 1
while page < 11: # GitHub limits to 1,000 results
print(f"Fetching page {page}...")
res = requests.get(f"https://api.github.com/search/issues?q=involves:{username}&per_page=100&page={page}",
auth=(username, password))
res.raise_for_status()
res = res.json()
items.extend(res["items"])
if len(res["items"]) < 100:
break
page += 1
json.dump(items, open(cache_name, "w"), indent=2)
items = json.load(open(cache_name))
ct = Counter()
for item in items:
splitkey = "/issues" if not "/pull/" in item["html_url"] else "/pull"
ct["/".join(item["html_url"].split(splitkey)[0].split("/")[-2:])] += 1
for proj, count in ct.most_common(20):
print(f"{count:5d} {proj}")
print(f" ...\nTotal: {len(ct)} projects")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment