fix: oprava zobrazení statistik pro aktuální týden
CI / Generate TypeScript types (push) Successful in 16s
CI / Server unit tests (push) Successful in 25s
CI / Build server (push) Successful in 28s
CI / Build client (push) Successful in 41s
CI / Playwright E2E tests (push) Successful in 1m46s
CI / Build and push Docker image (push) Successful in 48s
CI / Notify (push) Successful in 2s

This commit is contained in:
mates committed 2026-08-25 10:04:55 +02:00
1 parent 936ce2a9e4
commit 9027de5f8b
4 files changed
+40 -6

No files matched your search

+9 -3
View File
@@ -5,6 +5,9 @@ import getStorage from "./storage";
const storage = getStorage();
/** O kolik dní do budoucnosti smí sahat koncové datum požadovaného rozsahu. */
const MAX_FUTURE_DAYS = 7;
/**
* Vypočte a vrátí statistiky jednotlivých možností pro předaný rozsah dat.
*
@@ -25,9 +28,12 @@ export async function getStats(startDate: string, endDate: string): Promise<Week
throw new Error('Neplatný rozsah');
}
const today = new Date();
today.setHours(23, 59, 59, 999);
if (end > today) {
// Aktuální týden se načítá i s dny, které teprve budou — povolíme proto rozsah
// sahající maximálně týden do budoucnosti
const maxEnd = new Date();
maxEnd.setHours(23, 59, 59, 999);
maxEnd.setDate(maxEnd.getDate() + MAX_FUTURE_DAYS);
if (end > maxEnd) {
throw new Error('Nelze načíst statistiky pro budoucí datum');
}