mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 13:17:19 +01:00
Updated realtime data fetch.
This commit is contained in:
parent
04e0b33622
commit
e35c11c3d6
9 changed files with 126 additions and 87 deletions
|
|
@ -10,13 +10,11 @@ import { REALTIME_RANGE } from 'lib/constants';
|
|||
|
||||
export interface RealtimeRequestQuery {
|
||||
websiteId: string;
|
||||
timezone: string;
|
||||
}
|
||||
|
||||
const schema = {
|
||||
GET: yup.object().shape({
|
||||
websiteId: yup.string().uuid().required(),
|
||||
timezone: yup.string().required(),
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -25,7 +23,7 @@ export default async (req: NextApiRequestQueryBody<RealtimeRequestQuery>, res: N
|
|||
await useValidate(schema, req, res);
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { websiteId, timezone } = req.query;
|
||||
const { websiteId } = req.query;
|
||||
|
||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||
return unauthorized(res);
|
||||
|
|
@ -33,7 +31,7 @@ export default async (req: NextApiRequestQueryBody<RealtimeRequestQuery>, res: N
|
|||
|
||||
const startDate = subMinutes(startOfMinute(new Date()), REALTIME_RANGE);
|
||||
|
||||
const data = await getRealtimeData(websiteId, { startDate, timezone });
|
||||
const data = await getRealtimeData(websiteId, { startDate });
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue