;tools:buglist: prototype

This commit is contained in:
Simon Michael 2024-01-27 13:30:50 -10:00
parent fb1c223567
commit 5d90a89eda
2 changed files with 127 additions and 0 deletions

83
tools/buglist/app.orig.js Normal file
View File

@ -0,0 +1,83 @@
// A prototype of a custom issues list/dashboard.
// Copy this file (app.orig.js) to app.js for safety,
// and in app.js, set token to a github personal access token
// from https://github.com/settings/personal-access-tokens/new .
// Then open index.html in a browser.
const token = '';
const getIssues = (name) => {
// https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#list-repository-issues
// up to 100 most open bugs, most recently created first XXX with a severityN label
fetch(`https://api.github.com/repos/${name}/issues?per_page=100&labels=A-BUG`, //&label=severity1,severity2,severity3,severity4,severity5`,
{
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `token ${token}`
}
})
.then(response => response.json())
.then(data => {
// console.log(data)
showIssues(data);
})
.catch(error => console.error(error))
}
const showIssues = (data) => {
let t = document.getElementById('issues');
let r = t.insertRow();
r.innerHTML = `<th>User pain</th>`;
for (let i in data) {
let r = t.insertRow();
let issue = data[i];
c = r.insertCell();
c.style = `white-space:nowrap; font-weight:bold;`;
let imp = issueImpact(issue);
let sev = issueSeverity(issue);
let maxscore = 25; // max impact * max severity
let pain = (sev && imp) ? sev * imp / maxscore : '';
c.innerHTML = pain ? `${pain}` : '';
c = r.insertCell();
c.innerHTML = `<a href="${issue.html_url}">#${issue.number} ${issue.title}</a>`;
c = r.insertCell();
c.innerHTML = '';
let sortedlabels = issue.labels.toSorted( (a,b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()) );
for (let j in sortedlabels) { c.innerHTML += showLabel(sortedlabels[j]); }
// c = r.insertCell();
// c.innerHTML = `${iss.user.login}`;
}
}
const issueFindLabelWithPrefix = (issue, prefix) => {
for (let i in issue.labels) {
let l = issue.labels[i];
if (l.name.startsWith(prefix)) {return l.name;}
}
return '';
}
const issueSeverity = (issue) => {
let l = issueFindLabelWithPrefix(issue, 'severity');
return l ? l.replace('severity','') : '';
}
const issueImpact = (issue) => {
let l = issueFindLabelWithPrefix(issue, 'impact');
return l ? l.replace('impact','') : '';
}
const showLabel = (label) => {
cls = label.name.startsWith('severity') || label.name.startsWith('impact') ? 'paletag' : 'tag';
return ` <span class="${cls}" style="background-color:#${label.color};">` + label.name + '</span>';
}
getIssues('simonmichael/hledger');

44
tools/buglist/index.html Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hledger bugs dashboard</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<style>
body { padding:.5em; }
th { white-space: nowrap; }
tr { border-top:thin solid #eee; vertical-align:top; }
td { padding:0 1em; }
.tag { color:white; text-shadow: 2px 2px 2px black; font-size:small; padding:2px 8px 4px 6px; border-radius:1em; }
.paletag { color:black; font-weight:bold; font-size:small; padding:2px 8px 4px 6px; border-radius:1em; }
</style>
</head>
<body>
<h3 class="text-center">hledger open bugs</h3>
<p>
Currently our <a href="https://hledger.org/ISSUES.html#prioritising">user pain</a> score is
<i>Impact</i> (number of people affected, 1-5) <i>* Severity</i> (for those affected, 1-5) <i>/ 25</i>.
<br>
The possible scores are:
0.04
0.08
0.12
0.16
0.20
0.24
0.32
0.36
0.40
0.48
0.60
0.64
0.80
1.00
.
</p>
<table id="issues">
</table>
<script src="app.js"></script>
</body>
</html>