add nodesSeen

This commit is contained in:
Anton Roslund
2025-04-09 18:39:27 +02:00
parent f376f8557b
commit 056b8d61eb
2 changed files with 41 additions and 1 deletions
+20 -1
View File
@@ -7,6 +7,24 @@ draft: false
<br/>
{{% blocks/section color="white" %}}
## Antal Enheter
<div class="container my-4 mx-0" style="max-width: 1000px;">
<div class="row text-center px-0">
<div class="col">
<h2 class="display-4 text-primary" id="count-1"></h2>
<p class="text-muted">Hörts idag</p>
</div>
<div class="col">
<h2 class="display-4 text-warning" id="count-7"></h2>
<p class="text-muted">Senaste 7 dagarna</p>
</div>
<div class="col">
<h2 class="display-4 text-success" id="count-30"></h2>
<p class="text-muted">Senaste 30 dagarna</p>
</div>
</div>
</div>
## 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 >}}).
<div style="min-height: 300px;width: 100%;max-width: 1000px;">
@@ -65,4 +83,5 @@ Graferna baseras på data från [map.sthlm-mesh.se](https://map.sthlm-mesh.se),
<script src="/js/status/hardwareChart.js"></script>
<script src="/js/status/position-precision-chart.js"></script>
<script src="/js/status/portnum-distribution-chart.js"></script>
<script src="/js/status/device-roles.js"></script>
<script src="/js/status/device-roles.js"></script>
<script src="/js/status/nodes-seen.js"></script>
+21
View File
@@ -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();