feat(api): add insights endpoints

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-09-08 22:07:09 +02:00
parent d4a1eb88b8
commit df32bb04a0
21 changed files with 1340 additions and 416 deletions

View File

@@ -1,4 +1,4 @@
import { isSameDay, isSameMonth } from 'date-fns';
import { differenceInDays, isSameDay, isSameMonth } from 'date-fns';
export const DEFAULT_ASPECT_RATIO = 0.5625;
export const NOT_SET_VALUE = '(not set)';
@@ -232,6 +232,9 @@ export function getDefaultIntervalByDates(
if (isSameMonth(startDate, endDate)) {
return 'day';
}
if (differenceInDays(endDate, startDate) <= 31) {
return 'day';
}
return 'month';
}