mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
refactor(analytics): rename ninetyFiveDaysAgo + document tz day-key
This commit is contained in:
1 parent
aed890c9bb
commit
7032cb1b76
2 files changed
+14
-3
No files matched your search
@@ -147,21 +147,21 @@ async function computeFromRollups(
|
||||
// days ago. We read 396 days so the boundary day rolls cleanly into
|
||||
// the prior-year bucket without being dropped.
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
const ninetyFiveDaysAgo = new Date(now.getTime() - 396 * DAY_MS);
|
||||
const readSince = new Date(now.getTime() - 396 * DAY_MS);
|
||||
|
||||
const [sysBuckets, diaBuckets] = await Promise.all([
|
||||
readRollupBuckets(
|
||||
userId,
|
||||
"BLOOD_PRESSURE_SYS",
|
||||
"DAY",
|
||||
ninetyFiveDaysAgo,
|
||||
readSince,
|
||||
now,
|
||||
),
|
||||
readRollupBuckets(
|
||||
userId,
|
||||
"BLOOD_PRESSURE_DIA",
|
||||
"DAY",
|
||||
ninetyFiveDaysAgo,
|
||||
readSince,
|
||||
now,
|
||||
),
|
||||
]);
|
||||
|
||||
@@ -137,6 +137,17 @@ export async function computeCorrelationHypothesesFastPath(
|
||||
if (measurementsOnRollups) {
|
||||
// Rollup-fast-path. One indexed read per type against
|
||||
// `measurement_rollups`, projecting the per-day mean directly.
|
||||
//
|
||||
// The rollup table buckets at UTC midnight (`date_trunc('day', …)`
|
||||
// in Postgres). For a user whose display tz sits more than a few
|
||||
// hours from UTC the bucket's `bucketStart` can land on the
|
||||
// previous local calendar day relative to the same wall-clock
|
||||
// reading on the live path. Today the production tenant is
|
||||
// Berlin-centric (UTC+1/+2 → midnight UTC = 01:00/02:00 Berlin,
|
||||
// same calendar day) so the shift is benign. A v1.5 follow-up
|
||||
// could mint per-user-tz buckets if the discrepancy materialises
|
||||
// on a non-Berlin account; the n >= 20 surface gate absorbs the
|
||||
// single-day phase shift either way.
|
||||
const [sysBuckets, pulseBuckets, weightBuckets] = await Promise.all([
|
||||
readRollupBuckets(userId, "BLOOD_PRESSURE_SYS", "DAY", since, now),
|
||||
readRollupBuckets(userId, "PULSE", "DAY", since, now),
|
||||
|
||||
Reference in new issue
Block a user