mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
perf(analytics): thread source-priority once through correlations fast path
Load the source-priority blob once and pass it into the three readRollupBuckets calls instead of letting each re-query the user. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
38ef581e7a
commit
b45ca232fa
1 file changed
+7
-3
@@ -46,6 +46,7 @@
|
||||
import { prisma } from "@/lib/db";
|
||||
import { annotate } from "@/lib/logging/context";
|
||||
import { readRollupBuckets } from "@/lib/rollups/measurement-rollups";
|
||||
import { loadUserSourcePriority } from "@/lib/rollups/measurement-read";
|
||||
import {
|
||||
probeRollupCoverage,
|
||||
type RollupCoverageMap,
|
||||
@@ -168,10 +169,13 @@ export async function computeCorrelationHypothesesFastPath(
|
||||
// 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.
|
||||
// v1.11.2 — load the source-priority blob once and thread it into every
|
||||
// reader so the per-type fan-out doesn't re-query the user 3×.
|
||||
const priority = await loadUserSourcePriority(userId);
|
||||
const [sysBuckets, pulseBuckets, weightBuckets] = await Promise.all([
|
||||
readRollupBuckets(userId, "BLOOD_PRESSURE_SYS", "DAY", since, now),
|
||||
readRollupBuckets(userId, "PULSE", "DAY", since, now),
|
||||
readRollupBuckets(userId, "WEIGHT", "DAY", since, now),
|
||||
readRollupBuckets(userId, "BLOOD_PRESSURE_SYS", "DAY", since, now, priority),
|
||||
readRollupBuckets(userId, "PULSE", "DAY", since, now, priority),
|
||||
readRollupBuckets(userId, "WEIGHT", "DAY", since, now, priority),
|
||||
]);
|
||||
dailySysMean = new Map();
|
||||
for (const b of sysBuckets) {
|
||||
|
||||
Reference in new issue
Block a user