Filter nodes and hardware models to include only those updated in the last 30 days
This commit is contained in:
parent
7a86783ba4
commit
8fd496c59d
2 changed files with 10 additions and 0 deletions
|
|
@ -219,6 +219,10 @@ app.get('/api/v1/nodes', async (req, res) => {
|
||||||
where: {
|
where: {
|
||||||
role: role,
|
role: role,
|
||||||
hardware_model: hardwareModel,
|
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
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,12 @@ router.get('/hardware-models', async (req, res) => {
|
||||||
// get nodes from db
|
// get nodes from db
|
||||||
const results = await prisma.node.groupBy({
|
const results = await prisma.node.groupBy({
|
||||||
by: ['hardware_model'],
|
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: {
|
orderBy: {
|
||||||
_count: {
|
_count: {
|
||||||
hardware_model: 'desc',
|
hardware_model: 'desc',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue