- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpulls.py
More file actions
Latest commit
81 lines (75 loc) · 1.58 KB
/
Copy pathpulls.py
File metadata and controls
81 lines (75 loc) · 1.58 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3
fromgqlimportgql, Client, AIOHTTPTransport
fromosimportenviron
fromsysimportargv
transport=AIOHTTPTransport(
url="https://api.github.com/graphql",
headers={"Authorization": "bearer "+environ["GITHUB_TOKEN"]},
)
client=Client(transport=transport, fetch_schema_from_transport=True)
defmake_request(after=None):
ifafterisNone:
query=gql(
"""
query {
user(login: \""""
+argv[1]
+"""\") {
pullRequests(first: 100) {
edges {
node {
url
}
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
totalCount
}
}
}
"""
)
else:
query=gql(
"""
query {
user(login: \""""
+argv[1]
+"""\") {
pullRequests(first: 100, after: \""""
+after
+"""\") {
edges {
node {
url
}
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
totalCount
}
}
}
"""
)
result=client.execute(query)
foriinresult["user"]["pullRequests"]["edges"]:
print(i["node"]["url"])
ifresult["user"]["pullRequests"]["pageInfo"]["hasNextPage"]:
returnresult["user"]["pullRequests"]["pageInfo"]["endCursor"]
else:
print("totalCount: "+str(result["user"]["pullRequests"]["totalCount"]))
returnNone
after=None
whileTrue:
after=make_request(after=after)
ifafterisNone:
break