mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 22:02:16 +00:00
Make WHOOP-native recovery the canonical read
RECOVERY_SCORE is written by two sources for the same day: the WHOOP-native percentage from the device sync and the COMPUTED proxy from the nightly readiness job. The wellness reader hard-filtered to source COMPUTED, silently dropping every ingested native row, and the doctor PDF blended both sources into one min/avg/max. The COMPUTED proxy also equals the readiness blend verbatim, so the Coach prompt carried the same number under both READINESS and RECOVERY_SCORE. Add resolveCanonicalRecovery: per day, keep the WHOOP row when present, else the COMPUTED proxy. Drop the COMPUTED-only filter for RECOVERY in the wellness reader and resolve to the canonical row; STRESS and STRAIN stay COMPUTED-only. Resolve the doctor PDF wellness summary the same way so the report reads the native value, not a proxy/native blend. Dedup the Coach snapshot: omit the recovery line when it mirrors readiness (the no-native case), keep it when a WHOOP-native value differs. Document the WHOOP-over-COMPUTED resolution on the sync delta feed, which already mirrors each row with its source so the client resolves one canonical series rather than charting two. A WHOOP-connected user's recovery tile, chart, and PDF flip from the proxy to the native value.
This commit is contained in:
1 parent
b4b9d8d9d7
commit
eba01b37ce
9 files changed
+360
-11
No files matched your search
@@ -319,6 +319,15 @@ export const GET = apiHandler(async (request: NextRequest) => {
|
||||
updatedAt: row.updatedAt.toISOString(),
|
||||
});
|
||||
} else {
|
||||
// Every row carries its `source`. RECOVERY_SCORE is written by BOTH the
|
||||
// WHOOP-native sync (`source = WHOOP`) and the COMPUTED proxy job
|
||||
// (`source = COMPUTED`) for the same day; the client must resolve to ONE
|
||||
// canonical recovery series — WHOOP wins when present, COMPUTED is the
|
||||
// fallback — and never chart the proxy and the native value as two
|
||||
// competing series. The feed faithfully mirrors both rows (a delta-sync
|
||||
// mirror cannot drop a row mid-keyset without a tombstone); the
|
||||
// canonical pick is the same WHOOP-over-COMPUTED rule the server's
|
||||
// wellness tile + doctor PDF apply (`resolveCanonicalRecovery`).
|
||||
measurementUpserts.push({
|
||||
id: row.id,
|
||||
externalId: row.externalId,
|
||||
|
||||
Reference in new issue
Block a user