mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
fix UTC issues
This commit is contained in:
parent
004ccdc22f
commit
a15d0ca94a
6 changed files with 35 additions and 21 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import { NextApiResponse } from 'next';
|
|||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { pageInfo } from 'lib/schema';
|
||||
import { getWebsiteSessionsWeekly } from 'queries';
|
||||
import { TimezoneTest } from 'lib/yup';
|
||||
|
||||
export interface ReportsRequestQuery extends PageParams {
|
||||
websiteId: string;
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
const schema = {
|
||||
|
|
@ -16,6 +18,7 @@ const schema = {
|
|||
websiteId: yup.string().uuid().required(),
|
||||
startAt: yup.number().integer().required(),
|
||||
endAt: yup.number().integer().min(yup.ref('startAt')).required(),
|
||||
timezone: TimezoneTest,
|
||||
...pageInfo,
|
||||
}),
|
||||
};
|
||||
|
|
@ -28,7 +31,7 @@ export default async (
|
|||
await useAuth(req, res);
|
||||
await useValidate(schema, req, res);
|
||||
|
||||
const { websiteId, startAt, endAt } = req.query;
|
||||
const { websiteId, startAt, endAt, timezone } = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||
|
|
@ -38,7 +41,7 @@ export default async (
|
|||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
const data = await getWebsiteSessionsWeekly(websiteId, { startDate, endDate });
|
||||
const data = await getWebsiteSessionsWeekly(websiteId, { startDate, endDate, timezone });
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue