From 056b8d61eb34441d0ea4eb60b0a905a305b502d9 Mon Sep 17 00:00:00 2001 From: Anton Roslund Date: Wed, 9 Apr 2025 18:39:27 +0200 Subject: [PATCH] add nodesSeen --- content/sv/status/index.md | 21 ++++++++++++++++++++- static/js/status/nodes-seen.js | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 static/js/status/nodes-seen.js diff --git a/content/sv/status/index.md b/content/sv/status/index.md index 9f3ab67..71d139f 100644 --- a/content/sv/status/index.md +++ b/content/sv/status/index.md @@ -7,6 +7,24 @@ draft: false
{{% blocks/section color="white" %}} +## Antal Enheter +
+
+
+

+

Hörts idag

+
+
+

+

Senaste 7 dagarna

+
+
+

+

Senaste 30 dagarna

+
+
+
+ ## Text Meddelanden Antalet meddelanden per timme senaste 7 dygnen. Grafen visar meddelanden som skickats på LongFast kanalen, men även okrypterade meddelanden mellan noder. De meddelanden som skickas går att se [här]({{< ref messages >}}).
@@ -65,4 +83,5 @@ Graferna baseras på data från [map.sthlm-mesh.se](https://map.sthlm-mesh.se), - \ No newline at end of file + + \ No newline at end of file diff --git a/static/js/status/nodes-seen.js b/static/js/status/nodes-seen.js new file mode 100644 index 0000000..b7f8a70 --- /dev/null +++ b/static/js/status/nodes-seen.js @@ -0,0 +1,21 @@ + +async function nodesSeen() { + const response = await fetch('https://map.sthlm-mesh.se/api/v1/nodes/'); + const data = await response.json(); + const nodes = data.nodes; + const now = new Date(); + + + const countNodesSince = (daysAgo) => { + const threshold = new Date(now); + threshold.setDate(threshold.getDate() - daysAgo); + return nodes.filter(node => new Date(node.updated_at) >= threshold).length; + }; + + document.getElementById("count-30").textContent = countNodesSince(30); + document.getElementById("count-7").textContent = countNodesSince(7); + document.getElementById("count-1").textContent = countNodesSince(1); + +} + +nodesSeen(); \ No newline at end of file