diff --git a/src/index.js b/src/index.js index 02c5763..abffab1 100644 --- a/src/index.js +++ b/src/index.js @@ -266,6 +266,8 @@ app.get('/api/v1/nodes/:nodeId/power-metrics', async (req, res) => { const nodeId = parseInt(req.params.nodeId); const count = req.query.count ? parseInt(req.query.count) : undefined; + const timeFrom = req.query.time_from ? parseInt(req.query.time_from) : undefined; + const timeTo = req.query.time_to ? parseInt(req.query.time_to) : undefined; // find node const node = await prisma.node.findFirst({ @@ -286,6 +288,10 @@ app.get('/api/v1/nodes/:nodeId/power-metrics', async (req, res) => { const powerMetrics = await prisma.powerMetric.findMany({ where: { node_id: node.node_id, + created_at: { + gte: timeFrom ? new Date(timeFrom) : undefined, + lte: timeTo ? new Date(timeTo) : undefined, + }, }, orderBy: { id: 'desc', diff --git a/src/public/index.html b/src/public/index.html index b12e8ab..d0664ed 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -919,69 +919,67 @@
Power Metrics