This repository was archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathget_contributors.py
More file actions
53 lines (43 loc) · 1.47 KB
/
Copy pathget_contributors.py
File metadata and controls
53 lines (43 loc) · 1.47 KB
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
#
# Copyright 2021- IBM Inc. All rights reserved
# SPDX-License-Identifier: Apache2.0
#
import sys
import utils.github_utils as gh
from utils.cloudant_utils import cloudant_db as db, save_doc
def main(args):
try:
limit = int(args[0])
except:
limit = 50000
try:
skip = int(args[1])
except:
skip = 0
try:
sort = "asc" if args[2]=="asc" else "desc"
except:
sort = "desc"
print(limit, skip, sort)
repos = db.get_query_result({
"type":"Repo",
# "topics": { "$elemMatch": { "$in": ["machine-learning", "deep-learning" ] } },
#"contributions": { "$exists": False }
},["_id", "contributors_id"], limit=limit, skip=skip, raw_result=True, sort=[{'pushed_at': sort}] )["docs"]
print("repos", len(repos))
users = [ r["_id"] for r in db.get_query_result({"type":"User"},["_id"]) ]
print("users", len(users))
# crawl the repos
for repo in repos:
print("\n", repo["_id"])
try:
contributors = repo["contributors_id"] if "contributors_id" in repo else [c.login for c in gh.get_repo_by_fullname(repo["_id"]).contributors()]
for c in contributors:
print(c)
if c not in users:
gh.get_user(c, overwrite=False, details=False)
users.append(c)
except:
print("error gettinng users")
if __name__ == "__main__":
main(sys.argv[1:])