mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Use dataStartDate for resetDate.
This commit is contained in:
parent
ee8de858d1
commit
0f98fb5959
15 changed files with 172 additions and 85 deletions
|
|
@ -3,11 +3,10 @@ import { NextApiResponse } from 'next';
|
|||
import { badRequest, methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { NextApiRequestQueryBody, WebsitePageviews } from 'lib/types';
|
||||
import { canViewWebsite } from 'lib/auth';
|
||||
import { getAllowedUnits } from 'lib/date';
|
||||
import { useAuth, useCors } from 'lib/middleware';
|
||||
import { getPageviewStats } from 'queries';
|
||||
|
||||
const unitTypes = ['year', 'month', 'hour', 'day'];
|
||||
|
||||
export interface WebsitePageviewRequestQuery {
|
||||
id: string;
|
||||
startAt: number;
|
||||
|
|
@ -57,7 +56,7 @@ export default async (
|
|||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
if (!moment.tz.zone(timezone) || !unitTypes.includes(unit)) {
|
||||
if (!moment.tz.zone(timezone) || !getAllowedUnits(unit).includes(unit)) {
|
||||
return badRequest(res);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue