mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
Fix display of years.
This commit is contained in:
parent
84a8b51790
commit
a0cb278463
@ -4,6 +4,7 @@ import {
|
||||
addHours,
|
||||
addDays,
|
||||
addMonths,
|
||||
addYears,
|
||||
subHours,
|
||||
subDays,
|
||||
startOfHour,
|
||||
@ -19,6 +20,7 @@ import {
|
||||
differenceInHours,
|
||||
differenceInCalendarDays,
|
||||
differenceInCalendarMonths,
|
||||
differenceInCalendarYears,
|
||||
} from 'date-fns';
|
||||
|
||||
export function getTimezone() {
|
||||
@ -90,7 +92,7 @@ export function getDateRangeValues(startDate, endDate) {
|
||||
return { startDate: startOfHour(startDate), endDate: endOfHour(endDate), unit: 'hour' };
|
||||
} else if (differenceInCalendarDays(endDate, startDate) <= 90) {
|
||||
return { startDate: startOfDay(startDate), endDate: endOfDay(endDate), unit: 'day' };
|
||||
} else if (differenceInCalendarMonths(endDate, startDate) <= 12) {
|
||||
} else if (differenceInCalendarMonths(endDate, startDate) <= 24) {
|
||||
return { startDate: startOfMonth(startDate), endDate: endOfMonth(endDate), unit: 'month' };
|
||||
}
|
||||
return { startDate: startOfYear(startDate), endDate: endOfYear(endDate), unit: 'year' };
|
||||
@ -100,6 +102,7 @@ const dateFuncs = {
|
||||
hour: [differenceInHours, addHours, startOfHour],
|
||||
day: [differenceInCalendarDays, addDays, startOfDay],
|
||||
month: [differenceInCalendarMonths, addMonths, startOfMonth],
|
||||
year: [differenceInCalendarYears, addYears, startOfYear],
|
||||
};
|
||||
|
||||
export function getDateArray(data, startDate, endDate, unit) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "umami",
|
||||
"version": "0.30.0",
|
||||
"version": "0.31.0",
|
||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||
"author": "Mike Cao <mike@mikecao.com>",
|
||||
"license": "MIT",
|
||||
|
@ -3,7 +3,7 @@ import { getPageviews } from 'lib/queries';
|
||||
import { ok, badRequest, methodNotAllowed } from 'lib/response';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
|
||||
const unitTypes = ['month', 'hour', 'day'];
|
||||
const unitTypes = ['year', 'month', 'hour', 'day'];
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
Loading…
Reference in New Issue
Block a user