From 8fd496c59d1cf07719cf0c2b3f4770913f5ab101 Mon Sep 17 00:00:00 2001 From: Anton Roslund Date: Fri, 21 Nov 2025 22:05:31 +0100 Subject: [PATCH] Filter nodes and hardware models to include only those updated in the last 30 days --- src/index.js | 4 ++++ src/stats.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/index.js b/src/index.js index a51e465..9d482c1 100644 --- a/src/index.js +++ b/src/index.js @@ -219,6 +219,10 @@ app.get('/api/v1/nodes', async (req, res) => { where: { role: role, hardware_model: hardwareModel, + // Since we removed retention; only include nodes that have been updated in the last 30 days + updated_at: { + gte: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) // within last 30 days + } }, }); diff --git a/src/stats.js b/src/stats.js index 4d5e510..d02c538 100644 --- a/src/stats.js +++ b/src/stats.js @@ -21,6 +21,12 @@ router.get('/hardware-models', async (req, res) => { // get nodes from db const results = await prisma.node.groupBy({ by: ['hardware_model'], + where: { + // Since we removed retention; only include nodes that have been updated in the last 30 days + updated_at: { + gte: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) // within last 30 days + } + }, orderBy: { _count: { hardware_model: 'desc',