mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
The F1 coach tools each rebuild a snapshot with a distinct single-source scope, so the 60s snapshot LRU (keyed on the source list) never shares their reads. On a multi-metric turn the model can fan out up to six tools that each fire `extractFeatures` (a user lookup plus a windowed measurement read plus the all-time extremes) and a prefs `findUnique` concurrently — up to twelve heavy reads against the shared Prisma pool at once. Memoise both reads on the request-scoped event cache, keyed on userId (and windowDays for the features read), so the fan-out collapses to one of each within a request while staying correct across requests. Project the feature extractor's measurement read to the six columns its consumers actually use (type, value, measuredAt, sleepStage, source, deviceType) so the 200k-row-class PULSE / glucose windows stop pulling every column. Outputs are unchanged.