fix(api): use UTC in reports date helpers — reports show no data (GRO-302)
Fixes GRO-302. Reports page showed no data because date range helpers used local time instead of UTC for boundary calculations.
This commit was merged in pull request #186.
This commit is contained in:
committed by
GitHub
parent
0d610f5114
commit
2fd86d0636
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user