fix(api): use UTC in reports date helpers — reports show no data #186

Merged
groombook-engineer[bot] merged 3 commits from fix/gro-302-reports-no-data into main 2026-03-31 19:47:31 +00:00
Showing only changes of commit 89641d3c23 - Show all commits
+4 -4
View File
@@ -31,14 +31,14 @@ function parseDate(value: string | undefined, fallback: Date): Date {
function defaultFrom(): Date {
const d = new Date();
d.setDate(d.getDate() - 30);
d.setHours(0, 0, 0, 0);
d.setUTCDate(d.getUTCDate() - 30);
d.setUTCHours(0, 0, 0, 0);
return d;
}
function defaultTo(): Date {
const d = new Date();
d.setHours(23, 59, 59, 999);
d.setUTCHours(23, 59, 59, 999);
return d;
}
@@ -283,7 +283,7 @@ reportsRouter.get("/clients", async (c) => {
// Clients with no appointment in last 90 days (churn risk)
const ninetyDaysAgo = new Date();
ninetyDaysAgo.setDate(ninetyDaysAgo.getDate() - 90);
ninetyDaysAgo.setUTCDate(ninetyDaysAgo.getUTCDate() - 90);
const ninetyDaysAgoISO = ninetyDaysAgo.toISOString();
const churnRisk = await db