forked from taichi-dev/taichi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_active_contributors.py
57 lines (42 loc) · 1.52 KB
/
fetch_active_contributors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import requests
def print_active_contributors():
api_prefix = "https://api.github.com/repos/taichi-dev/taichi"
per_page = 100
contributors = []
page = 1
while True:
contributors_json = requests.get(f"{api_prefix}/contributors?per_page={per_page}&page={page}").json()
for c in contributors_json:
contributors.append(c["login"])
if len(contributors_json) == 0:
break
page += 1
print(len(contributors), contributors)
counter = {}
irregular_records = set()
page = 1
eof = False
while not eof:
# Note: for some reason the 'page' argument is 1-based
commits_json = requests.get(f"{api_prefix}/commits?per_page={per_page}&page={page}").json()
for c in commits_json:
date = c["commit"]["committer"]["date"]
try:
author = c["author"]["login"]
except:
irregular_records.add(c["commit"]["author"]["email"])
continue
if int(date[:4]) < 2020:
eof = True
break
print(date, author)
if author in contributors:
counter[author] = counter.get(author, 0) + 1
print("---")
page += 1
for login, contrib in sorted(list(counter.items()), key=lambda rec: -rec[1]):
print(f"- [{login}](https://github.com/{login}/) {contrib}")
print("Irregular records:")
print(irregular_records)
if __name__ == "__main__":
print_active_contributors()