Skip to content

Instantly share code, notes, and snippets.

@joakin
Last active October 4, 2017 16:54
Show Gist options
  • Save joakin/61cfcf30d81f73f768c10c7476eae81d to your computer and use it in GitHub Desktop.
Save joakin/61cfcf30d81f73f768c10c7476eae81d to your computer and use it in GitHub Desktop.
Get percentage stats of number of projects from phlogiston table
// Run it on http://phlogiston-dev.wmflabs.org/red_status_report.html
// Open devtools, paste all contents
var tbody = document.querySelector("table.bord tbody.list");
var trs = Array.from(tbody.childNodes);
var trsCount = trs.reduce((a, tr) => {
var cell = tr.querySelector("td").textContent;
a[cell] = (a[cell] || 0) + 1;
return a;
}, {});
var trsCountsArr = Object.entries(trsCount)
.sort((a, b) => (a[1] < b[1] ? -1 : 1))
.reverse();
var stats = trsCountsArr.map(r => r.join(" => ") + " tasks").join("\n");
console.log("Projects & tasks");
console.log(stats);
var total = trs.length;
stats = trsCountsArr
.map(r => {
r2 = r.slice();
r2[1] = (r[1] * 100 / total).toFixed(1) + "%";
return r2.join(" => ");
})
.join("\n");
console.log();
console.log("Projects & percentage of total");
console.log(stats);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment