graphs: make interval configurable

This commit is contained in:
Girish Ramakrishnan
2025-05-20 19:09:12 +02:00
parent 3428b95672
commit 892ff38a3f
8 changed files with 44 additions and 41 deletions

View File

@@ -118,11 +118,13 @@ async function getLogStream(req, res, next) {
}
async function getSystemGraphs(req, res, next) {
if (!req.query.fromMinutes || !parseInt(req.query.fromMinutes)) return next(new HttpError(400, 'fromMinutes must be a number'));
if (!req.query.fromSecs || !parseInt(req.query.fromSecs)) return next(new HttpError(400, 'fromSecs must be a number'));
if (!req.query.intervalSecs || !parseInt(req.query.intervalSecs)) return next(new HttpError(400, 'intervalSecs must be a number'));
const fromMinutes = parseInt(req.query.fromMinutes);
const fromSecs = parseInt(req.query.fromSecs);
const intervalSecs = parseInt(req.query.intervalSecs);
const noNullPoints = !!req.query.noNullPoints;
const [error, result] = await safe(graphs.getSystem(fromMinutes, noNullPoints));
const [error, result] = await safe(graphs.getSystem({ fromSecs, intervalSecs, noNullPoints }));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, result));