mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
fix(ai): count the daily AI budget on the account's own day
The token ledger keyed every day on UTC while the daily briefing and the other per-day generations run on the account's local day, so east of UTC the first generations after local midnight were refused against the previous day's spent ceiling. The budget day is now the calendar day in the account's time zone; each request still resolves it once and books its reservation and reconcile on the same row. The medication extraction reads relative phrases against the same local day, the operator's spend card shows the operator's own day, and the limit copy says the budget resets at midnight in the person's time zone.
This commit is contained in:
1 parent
7d8ff0f2df
commit
dcb7a0bc09
35 files changed
+175
-65
No files matched your search
@@ -73,11 +73,13 @@ interface ProviderHealthSummary {
|
||||
const CENTRAL_TYPES = [...OPERATOR_HELD_PROVIDER_TYPES];
|
||||
|
||||
export const GET = apiHandler(async () => {
|
||||
await requireAdmin();
|
||||
const { user } = await requireAdmin();
|
||||
annotate({ action: { name: "admin.provider-health.get" } });
|
||||
|
||||
// The UTC day the ledger buckets by — the same key every reservation writes.
|
||||
const dateKey = buildDateKey();
|
||||
// The ledger buckets each account by its own local day; the operator's
|
||||
// "today" is the day in the operator's own zone, which on a single-zone
|
||||
// instance is everyone's.
|
||||
const dateKey = await buildDateKey(user.id);
|
||||
|
||||
const groups = await prisma.providerHealth.groupBy({
|
||||
// `lastStatus` joins the grouping key rather than an aggregate: the
|
||||
|
||||
Reference in new issue
Block a user