This repository was archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_histogram.py
66 lines (51 loc) · 1.71 KB
/
generate_histogram.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
import datetime
import os
import matplotlib.pyplot as plt
from github import Github
# This is the generic report of the histogram issues of the repository,
# this will must be manually generated by running the
# 'histogram_general_report_generator.yml' workflow
token = os.getenv('GITHUB_TOKEN')
repo_name = "Computer-Engineering-UdL/JointProject"
g = Github(token)
repo = g.get_repo(repo_name)
labels_count = {
"back-end": 0,
"bug": 0,
"database": 0,
"documentation": 0,
"front-end": 0,
"tests": 0,
"wontfix": 0,
"user-story": 0,
}
def get_date() -> str:
"""The format is: MX -> where X is number of month"""
now = datetime.datetime.now()
month = now.strftime("%m")
return f"M{month}"
# This is the state of the issues that this is gathering:
# "all" - All issues assigned to the repository
# "open" - Open issues assigned to the repository
# "closed" - Closed issues assigned to the repository
def count_labels(state="all") -> None:
"""Count the number of issues with each label"""
for issue in repo.get_issues(state=state):
for label in issue.labels:
if label.name in labels_count:
labels_count[label.name] += 1
def generate_plot() -> None:
"""Generate a histogram of the number of issues with each label"""
plt.figure(figsize=(10, 6))
plt.bar(labels_count.keys(), labels_count.values())
plt.ylabel('Number of Issues')
plt.title('Histogram of Issues by Label - General Report')
plt.xticks(rotation=20)
plt.yticks(range(0, max(labels_count.values()) + 1, 5))
plt.tight_layout()
plt.savefig("histogram_issues.png")
def main() -> None:
count_labels()
generate_plot()
if __name__ == '__main__':
main()