Files
HealthLog/src/lib
Marc-André Bombeck 337f024a87 feat(whoop): pg-boss sync workers + self-converging backfill
Build the WHOOP sync layer on the W2 client, mirroring the Withings
queues. A per-resource sync (recovery/sleep/cycle/workout) pulls since
the last cursor with a 24h overlap on recovery/sleep to absorb WHOOP's
after-the-fact re-scoring, maps via the W2 mappers, and upserts
Measurements with source=WHOOP keyed on (userId,type,source,externalId)
so a re-post overwrites in place. Workouts upsert into Workout with
per-workout strain + HR zones in metadata and kJ->kcal energy.

Token refresh persists BOTH rotated tokens (WHOOP invalidates the prior
access and refresh token on every refresh). A self-converging boot
backfill enqueues one full-history sync per un-backfilled connection and
stamps backfillCompletedAt; the discovery query drops completed accounts,
idempotent across reboots.

Every new queue is registered in the worker's allQueues + cron schedule
(recovery/sleep/workout poll catch-all, cycle poll-only, backfill,
oauth-state sweep). IntegrationStatus gains the whoop key + label.

Tests: rotating-refresh persistence, idempotent measurement upsert,
incremental-window overlap, backfill self-convergence, and a
queue-registration inventory guard.
2026-06-04 01:21:42 +02:00
..
2026-05-14 23:49:32 +02:00
2026-05-31 14:36:17 +02:00
2026-05-29 22:07:10 +02:00
2026-05-31 14:36:17 +02:00
2026-05-31 14:36:17 +02:00
2026-05-31 14:36:17 +02:00
2026-05-31 14:36:17 +02:00
2026-05-31 14:36:17 +02:00
2026-05-14 23:49:32 +02:00
2026-03-10 20:14:33 +01:00
2026-05-14 23:49:32 +02:00
2026-05-17 23:46:09 +02:00
2026-03-10 20:14:33 +01:00