mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
Added parseDateRangeQuery function.
This commit is contained in:
parent
09af33c77e
commit
1648707fc7
9 changed files with 48 additions and 80 deletions
|
|
@ -62,10 +62,10 @@ export function parseDateRange(value, locale = 'en-US') {
|
|||
}
|
||||
|
||||
if (value?.startsWith?.('range')) {
|
||||
const [, startAt, endAt] = value.split(':');
|
||||
const [, startTime, endTime] = value.split(':');
|
||||
|
||||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
const startDate = new Date(+startTime);
|
||||
const endDate = new Date(+endTime);
|
||||
|
||||
return {
|
||||
...getDateRangeValues(startDate, endDate),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ export async function parseDateRangeQuery(req: NextApiRequest) {
|
|||
const { min, max } = await getWebsiteDateRange(websiteId as string);
|
||||
|
||||
return {
|
||||
websiteId,
|
||||
startDate: min,
|
||||
endDate: max,
|
||||
unit: getMinimumUnit(min, max),
|
||||
|
|
@ -22,9 +21,8 @@ export async function parseDateRangeQuery(req: NextApiRequest) {
|
|||
const minUnit = getMinimumUnit(startDate, endDate);
|
||||
|
||||
return {
|
||||
websiteId,
|
||||
startDate,
|
||||
endDate,
|
||||
unit: getAllowedUnits(startDate, endDate).includes(unit as string) ? unit : minUnit,
|
||||
unit: (getAllowedUnits(startDate, endDate).includes(unit as string) ? unit : minUnit) as string,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue