Filter nodes and hardware models to include only those updated in the last 30 days

This commit is contained in:
Anton Roslund 2025-11-21 22:05:31 +01:00
parent 7a86783ba4
commit 8fd496c59d
2 changed files with 10 additions and 0 deletions

View file

@ -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
}
},
});

View file

@ -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',