Skip to content

Commit a03d8e6

Browse files
author
hoang.tran12
committed
update
1 parent ebaafcb commit a03d8e6

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

scripts/_ufs_statistic.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,23 @@ export default {
8282
(scriptNameCount.get(scriptName) || 0) + 1
8383
);
8484
});
85+
86+
// sort by values
87+
const scriptNameCountSorted = new Map(
88+
[...scriptNameCount.entries()].sort((a, b) => b[1] - a[1])
89+
);
90+
8591
const canvas2 = document.createElement("canvas");
8692
canvas2.style.cssText = "max-width: 300px; max-height: 300px;";
8793
document.body.prepend(canvas2);
8894
const ctx2 = canvas2.getContext("2d");
8995
const scriptNameChart = new Chart(ctx2, {
9096
type: "doughnut",
9197
data: {
92-
labels: Array.from(scriptNameCount.keys()),
98+
labels: Array.from(scriptNameCountSorted.keys()),
9399
datasets: [
94100
{
95-
data: Array.from(scriptNameCount.values()),
101+
data: Array.from(scriptNameCountSorted.values()),
96102
backgroundColor: [
97103
"rgb(255, 99, 132)",
98104
"rgb(255, 159, 64)",
@@ -111,6 +117,10 @@ export default {
111117
legend: {
112118
display: false,
113119
},
120+
title: {
121+
display: true,
122+
text: `Number of logs per script name (${scriptNameCount.size} scripts)`,
123+
},
114124
},
115125
responsive: true,
116126
},
@@ -167,6 +177,13 @@ export default {
167177
},
168178
},
169179
});
180+
181+
// ======================== Average section ========================
182+
const h1 = document.createElement("h1");
183+
h1.textContent = `${logData.length} logs,
184+
${scriptNameCount.size} scripts used
185+
(~${~~(logData.length / new Date().getHours())} scripts/hour)`;
186+
document.body.prepend(h1);
170187
}
171188
);
172189
})();

0 commit comments

Comments
 (0)