implement new power metrics chart for voltage and current

This commit is contained in:
liamcottle
2024-09-02 14:06:58 +12:00
parent ffa68a6f2c
commit 2664a3ef52
2 changed files with 181 additions and 212 deletions

View File

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