-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_issue_list_pv2.py
68 lines (59 loc) · 1.97 KB
/
get_issue_list_pv2.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
58
59
60
61
62
63
64
65
66
67
68
import requests
# Replace with your GitHub Personal Access Token and repository details
ACCESS_TOKEN = "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"
REPO_OWNER = "RhoderickGalero"
REPO_NAME = "Practice"
def get_repository_issues():
url = "https://api.github.com/graphql"
headers = {
"Authorization": f"Bearer {ACCESS_TOKEN}"
}
query = """
{
repository(owner: "%s", name: "%s") {
projectV2(number: 6) {
id
items(first: 10) {
edges {
node {
id
content {
... on Issue {
id
assignees(first: 10) {
edges {
node {
id
}
}
}
}
}
}
}
}
}
}
}
""" % (REPO_OWNER, REPO_NAME)
response = requests.post(url, json={"query": query}, headers=headers)
# print (response)
if response.status_code == 200:
data = response.json()
# print (data)
issues = data["data"]["repository"]["projectV2"]["items"]["edges"]
print (issues)
return issues
else:
print("Failed to retrieve issues:", response.text)
return None
if __name__ == "__main__":
issues = get_repository_issues()
for item in issues:
assignees_edges = item["node"]["content"]
# print (assignees_edges)
if assignees_edges:
node_id = item["node"]["id"]
print (node_id)
# empty_assignees_node_ids.append(node_id)
#print(empty_assignees_node_ids)