Add bug count and issues link to generated chart page

Display the current open bug total on the chart page and add a link to the Forgejo issues list.

Also document optional forgejo.issues_url in config.

Closes #3

Closes #2
This commit is contained in:
Edward Betts 2026-02-17 14:26:49 +00:00
parent 0aaabd8671
commit e575848c6d
3 changed files with 11 additions and 1 deletions

View file

@ -23,6 +23,7 @@ Create a configuration file with the following structure:
[forgejo] [forgejo]
hostname=<Your Forgejo hostname> hostname=<Your Forgejo hostname>
token=<Your Forgejo Token> token=<Your Forgejo Token>
issues_url=<Optional URL to your issue list>
[output] [output]
dest=<Path to output HTML file> dest=<Path to output HTML file>

View file

@ -107,14 +107,19 @@ def main() -> None:
open_bugs_over_time = count_open_bugs(bug_reports) open_bugs_over_time = count_open_bugs(bug_reports)
json_data = json.dumps(open_bugs_over_time) json_data = json.dumps(open_bugs_over_time)
current_open_bug_count = open_bugs_over_time[-1][1] if open_bugs_over_time else 0
bug_list_url = config.get("forgejo", "issues_url", fallback=f"https://{hostname}/issues")
script_dir = os.path.dirname(os.path.abspath(__file__)) script_dir = os.path.dirname(os.path.abspath(__file__))
template_path = os.path.join(script_dir, "template.html") template_path = os.path.join(script_dir, "template.html")
with open(template_path, "r") as fh: with open(template_path, "r") as fh:
template_html = fh.read() template_html = fh.read()
page_html = template_html.replace("jsonData = []", "jsonData = " + json_data)
page_html = page_html.replace("__OPEN_BUG_COUNT__", str(current_open_bug_count))
page_html = page_html.replace("__BUG_LIST_URL__", bug_list_url)
dest = config.get("output", "dest") dest = config.get("output", "dest")
with open(dest, "w") as out: with open(dest, "w") as out:
out.write(template_html.replace("jsonData = []", "jsonData = " + json_data)) out.write(page_html)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -10,6 +10,10 @@
</head> </head>
<body> <body>
<p>
Open bugs now: <strong>__OPEN_BUG_COUNT__</strong> -
<a href="__BUG_LIST_URL__">Bug list</a>
</p>
<canvas id="bugChart" width="800" height="400"></canvas> <canvas id="bugChart" width="800" height="400"></canvas>
<script> <script>