fix UTC issues
This commit is contained in:
@@ -7,14 +7,17 @@ import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { getRealtimeData } from 'queries';
|
||||
import * as yup from 'yup';
|
||||
import { REALTIME_RANGE } from 'lib/constants';
|
||||
import { TimezoneTest } from 'lib/yup';
|
||||
|
||||
export interface RealtimeRequestQuery {
|
||||
websiteId: string;
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
const schema = {
|
||||
GET: yup.object().shape({
|
||||
websiteId: yup.string().uuid().required(),
|
||||
timezone: TimezoneTest,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -23,7 +26,7 @@ export default async (req: NextApiRequestQueryBody<RealtimeRequestQuery>, res: N
|
||||
await useValidate(schema, req, res);
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { websiteId } = req.query;
|
||||
const { websiteId, timezone } = req.query;
|
||||
|
||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||
return unauthorized(res);
|
||||
@@ -31,7 +34,7 @@ export default async (req: NextApiRequestQueryBody<RealtimeRequestQuery>, res: N
|
||||
|
||||
const startDate = subMinutes(startOfMinute(new Date()), REALTIME_RANGE);
|
||||
|
||||
const data = await getRealtimeData(websiteId, { startDate });
|
||||
const data = await getRealtimeData(websiteId, { startDate, timezone });
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user