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,
|
addHours,
|
||||||
addDays,
|
addDays,
|
||||||
addMonths,
|
addMonths,
|
||||||
|
addYears,
|
||||||
subHours,
|
subHours,
|
||||||
subDays,
|
subDays,
|
||||||
startOfHour,
|
startOfHour,
|
||||||
@ -19,6 +20,7 @@ import {
|
|||||||
differenceInHours,
|
differenceInHours,
|
||||||
differenceInCalendarDays,
|
differenceInCalendarDays,
|
||||||
differenceInCalendarMonths,
|
differenceInCalendarMonths,
|
||||||
|
differenceInCalendarYears,
|
||||||
} from 'date-fns';
|
} from 'date-fns';
|
||||||
|
|
||||||
export function getTimezone() {
|
export function getTimezone() {
|
||||||
@ -90,7 +92,7 @@ export function getDateRangeValues(startDate, endDate) {
|
|||||||
return { startDate: startOfHour(startDate), endDate: endOfHour(endDate), unit: 'hour' };
|
return { startDate: startOfHour(startDate), endDate: endOfHour(endDate), unit: 'hour' };
|
||||||
} else if (differenceInCalendarDays(endDate, startDate) <= 90) {
|
} else if (differenceInCalendarDays(endDate, startDate) <= 90) {
|
||||||
return { startDate: startOfDay(startDate), endDate: endOfDay(endDate), unit: 'day' };
|
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: startOfMonth(startDate), endDate: endOfMonth(endDate), unit: 'month' };
|
||||||
}
|
}
|
||||||
return { startDate: startOfYear(startDate), endDate: endOfYear(endDate), unit: 'year' };
|
return { startDate: startOfYear(startDate), endDate: endOfYear(endDate), unit: 'year' };
|
||||||
@ -100,6 +102,7 @@ const dateFuncs = {
|
|||||||
hour: [differenceInHours, addHours, startOfHour],
|
hour: [differenceInHours, addHours, startOfHour],
|
||||||
day: [differenceInCalendarDays, addDays, startOfDay],
|
day: [differenceInCalendarDays, addDays, startOfDay],
|
||||||
month: [differenceInCalendarMonths, addMonths, startOfMonth],
|
month: [differenceInCalendarMonths, addMonths, startOfMonth],
|
||||||
|
year: [differenceInCalendarYears, addYears, startOfYear],
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getDateArray(data, startDate, endDate, unit) {
|
export function getDateArray(data, startDate, endDate, unit) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "0.30.0",
|
"version": "0.31.0",
|
||||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -3,7 +3,7 @@ import { getPageviews } from 'lib/queries';
|
|||||||
import { ok, badRequest, methodNotAllowed } from 'lib/response';
|
import { ok, badRequest, methodNotAllowed } from 'lib/response';
|
||||||
import { useAuth } from 'lib/middleware';
|
import { useAuth } from 'lib/middleware';
|
||||||
|
|
||||||
const unitTypes = ['month', 'hour', 'day'];
|
const unitTypes = ['year', 'month', 'hour', 'day'];
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
await useAuth(req, res);
|
await useAuth(req, res);
|
||||||
|
Loading…
Reference in New Issue
Block a user