Fixed realtime chart display.

This commit is contained in:
Mike Cao 2023-02-17 21:42:42 -08:00
parent 93b77672f3
commit 802c262cd9
14 changed files with 112 additions and 75 deletions

View file

@ -9,9 +9,14 @@ export default async (req: NextApiRequestAuth, res: NextApiResponse<RealtimeInit
await useAuth(req, res);
if (req.method === 'GET') {
const { id } = req.query;
const { id, startAt } = req.query;
let startTime = subMinutes(new Date(), 30);
const data = await getRealtimeData(id, subMinutes(new Date(), 30));
if (+startAt > startTime.getTime()) {
startTime = new Date(+startAt);
}
const data = await getRealtimeData(id, startTime);
return ok(res, data);
}