-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueryproject
executable file
·74 lines (62 loc) · 2.2 KB
/
queryproject
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
#!/usr/bin/python3
import subprocess
import json
command = """
gh api graphql -f query='
query{
node(id: "PVT_kwHOABF2LM4AhB76") {
... on ProjectV2 {
items(first: 20) {
nodes{
fieldValues(last: 1) {
nodes{
... on ProjectV2ItemFieldSingleSelectValue {
name
field {
... on ProjectV2FieldCommon {
name
}
}
}
}
}
content{
... on DraftIssue {
title
}
...on Issue {
title
}
}
}
}
}
}
}'
"""
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode == 0:
output = result.stdout.decode("utf-8")
json_data = json.loads(output)
statuses = set()
status_counts = {}
items = (json_data["data"]["node"]["items"]["nodes"])
for item in items:
title_ = item["content"]["title"]
status = item["fieldValues"]["nodes"][-1]["name"]
statuses.add(status)
status_counts[status] = status_counts.get(status, 0) + 1
badges = ["", "", "", ""]
for status in statuses:
if status == "Backlog":
badges[0] = (f"![Static Badge](https://img.shields.io/badge/{status}-{status_counts[status]}-red?style=for-the-badge)")
if status == "Prioritized":
badges[1] =(f"![Static Badge](https://img.shields.io/badge/{status}-{status_counts[status]}-yellow?style=for-the-badge)")
if status == "Doing":
badges[2] = (f"![Static Badge](https://img.shields.io/badge/{status}-{status_counts[status]}-green?style=for-the-badge)")
if status == "Done":
badges[3] = (f"![Static Badge](https://img.shields.io/badge/{status}-{status_counts[status]}-blue?style=for-the-badge)")
print("\n\n".join(badges))
else:
error_message = result.stderr.decode("utf-8")
print(f"Error: {error_message}")