aboutsummaryrefslogtreecommitdiff
path: root/174bg/database/volumes/pocketbase
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-07-24 20:10:53 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-07-24 20:10:53 +0100
commit7dfd7b404cdcf0db8e44a8b357cd108e10a725e1 (patch)
treee92fbf31cde6107e818777c8488fa61a67f3e9ff /174bg/database/volumes/pocketbase
parenteb719a5416391521d536980e974f97b7ac8b78e3 (diff)
downloadunnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar
unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar.gz
unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar.bz2
unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.tar.xz
unnamed-group-7dfd7b404cdcf0db8e44a8b357cd108e10a725e1.zip
better arch of stats
Diffstat (limited to '174bg/database/volumes/pocketbase')
-rw-r--r--174bg/database/volumes/pocketbase/pb_hooks/stats.pb.js18
-rw-r--r--174bg/database/volumes/pocketbase/pb_hooks/views/stats.html23
2 files changed, 29 insertions, 12 deletions
diff --git a/174bg/database/volumes/pocketbase/pb_hooks/stats.pb.js b/174bg/database/volumes/pocketbase/pb_hooks/stats.pb.js
index e2b6ab3..3c9617b 100644
--- a/174bg/database/volumes/pocketbase/pb_hooks/stats.pb.js
+++ b/174bg/database/volumes/pocketbase/pb_hooks/stats.pb.js
@@ -1,6 +1,6 @@
routerAdd("get", "/stats", (e) => {
- const heartbeat = $http.send({
- url: "https://db.174bg.net/api/heartbeat",
+ const stats = $http.send({
+ url: "https://db.174bg.net/api/stats",
headers: { "content-type": "application/json" }
})
@@ -8,7 +8,17 @@ routerAdd("get", "/stats", (e) => {
`${__hooks}/views/_layout.html`,
`${__hooks}/views/stats.html`,
).render({
- "timeDifference": heartbeat.json.timeDifference,
- "withinThreshold": heartbeat.json.withinThreshold,
+ stats: stats.json,
}))
+})
+
+routerAdd("get", "/api/stats", (e) => {
+ const heartbeat = $http.send({
+ url: "https://db.174bg.net/api/heartbeat",
+ headers: { "content-type": "application/json" }
+ })
+
+ return e.json(200, {
+ heartbeat: heartbeat.json,
+ })
}) \ No newline at end of file
diff --git a/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html b/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html
index b59c1a7..b61a1ba 100644
--- a/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html
+++ b/174bg/database/volumes/pocketbase/pb_hooks/views/stats.html
@@ -3,8 +3,7 @@
{{end}}
{{define "body"}}
- <p id="timeDifference">Time Difference: {{.timeDifference}}</p>
- <p id="withinThreshold">Within Threshold: {{.withinThreshold}}</p>
+ <p id="app"></p>
<script>
window.addEventListener("load", () => {
@@ -12,14 +11,22 @@
});
async function fetchStats() {
- let heartbeat = await fetch("/api/heartbeat");
- heartbeat = await heartbeat.json();
+ let stats = await fetch("/api/stats");
+ stats = await stats.json();
+ document.getElementById("app").innerHTML = jsonToHtml(stats);
+ }
- const timeDifference = heartbeat.timeDifference;
- const withinThreshold = heartbeat.withinThreshold;
+ function jsonToHtml(json) {
+ if (json === null || typeof json !== "object") {
+ return String(json);
+ }
- document.getElementById("timeDifference").textContent = `Time Difference: ${timeDifference}`;
- document.getElementById("withinThreshold").textContent = `Within Threshold: ${withinThreshold}`;
+ let html = "<ul>";
+ for (const [key, value] of Object.entries(json)) {
+ html += `<li>${key}: ${typeof value === "object" && value !== null ? jsonToHtml(value) : String(value)}</li>`;
+ }
+ html += "</ul>";
+ return html;
}
</script>
{{end}} \ No newline at end of file