From 5fd69f9a559df0c37fe5ae04bd2a5949497a76bd Mon Sep 17 00:00:00 2001 From: ajvpot <553597+ajvpot@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:00:00 +0000 Subject: [PATCH] stats --- src/app/api/stats/nodes-over-time/route.ts | 12 ++++++------ src/app/stats/page.tsx | 11 +++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/app/api/stats/nodes-over-time/route.ts b/src/app/api/stats/nodes-over-time/route.ts index b7f1ae1..884487d 100644 --- a/src/app/api/stats/nodes-over-time/route.ts +++ b/src/app/api/stats/nodes-over-time/route.ts @@ -4,22 +4,22 @@ import { clickhouse } from "@/lib/clickhouse/clickhouse"; export async function GET() { try { const query = ` - WITH days AS ( - SELECT arrayJoin(range(0, 7)) AS offset, toDate(subtractDays(today(), 6 - offset)) AS day - ), - all_nodes AS ( + WITH all_nodes AS ( SELECT toDate(ingest_timestamp) AS day, public_key, latitude, longitude FROM meshcore_adverts - WHERE ingest_timestamp >= subtractDays(today(), 7) ), node_days AS ( SELECT public_key, min(day) AS first_seen, any(latitude) AS latitude, any(longitude) AS longitude FROM all_nodes GROUP BY public_key ), + all_days AS ( + SELECT DISTINCT day FROM all_nodes + ORDER BY day ASC + ), expanded AS ( SELECT d.day, nd.public_key, nd.latitude, nd.longitude - FROM days d + FROM all_days d INNER JOIN node_days nd ON nd.first_seen <= d.day ) SELECT day, diff --git a/src/app/stats/page.tsx b/src/app/stats/page.tsx index 557ed1e..5eb596e 100644 --- a/src/app/stats/page.tsx +++ b/src/app/stats/page.tsx @@ -27,14 +27,6 @@ export default function StatsPage() { return (
- Note: The “Nodes Heard Over Time” data shows activity from the past 7 days. - This provides a focused view of recent network activity while maintaining good performance. -
-+ Shows nodes heard within the last 7 days by date. +