Add data to admin page for success/fail history

This commit is contained in:
jude
2023-07-30 19:09:48 +01:00
parent b8707bbc9a
commit d5fa8036e8
3 changed files with 105 additions and 0 deletions

View File

@ -6,6 +6,21 @@ document.addEventListener("DOMContentLoaded", () => {
document.querySelector("#reminders").textContent = data.count.reminders;
document.querySelector("#intervals").textContent = data.count.intervals;
let historySent = data.historyLong.sent.reduce(
(iv, frame) => iv + frame.count,
0
);
let historyFailed = data.historyLong.failed.reduce(
(iv, frame) => iv + frame.count,
0
);
document.querySelector("#historySent").textContent = historySent;
document.querySelector("#historyFailed").textContent = historyFailed;
document.querySelector("#failRate").textContent = `${
(historyFailed / (historySent + historyFailed)) * 100
}%`;
new Chart(document.getElementById("schedule"), {
type: "bar",
data: {
@ -77,5 +92,40 @@ document.addEventListener("DOMContentLoaded", () => {
},
},
});
new Chart(document.getElementById("historyLong"), {
type: "bar",
data: {
labels: [...data.historyLong.sent, ...data.historyLong.failed].map(
(row) => luxon.DateTime.fromISO(row.time_key)
),
datasets: [
{
label: "Success",
data: data.historyLong.sent.map((row) => row.count),
},
{
label: "Fail",
data: data.historyLong.failed.map((row) => row.count),
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
stacked: true,
type: "time",
time: {
unit: "day",
},
},
y: {
stacked: true,
},
},
},
});
});
});