mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 22:02:16 +00:00
Two new pg-boss queues join the existing reminder-worker orchestrator: withings-activity-sync — cron '0 * * * *' (hourly at :00) withings-sleep-sync — cron '15 * * * *' (hourly at :15, offset) Each queue's handler dispatches per-user: when the payload carries `userId` (webhook-triggered) only that user syncs; when `userId` is absent (cron-triggered) the worker iterates every WithingsConnection. Per-user failures log as warnings so one parked-at-reauth connection doesn't starve the rest on a cron tick. The webhook handler now reads the `appli` form / JSON field and dispatches: appli=16 → enqueue withings-activity-sync (W17b) appli=44 → enqueue withings-sleep-sync (W17c) appli=1/2/4 or missing → legacy syncUserMeasurements (unchanged) When pg-boss is unavailable (dev server without the worker process) the handler falls back to inline sync so dev iteration isn't blocked on a separate worker process. The 15-minute cadence offset between activity (:00) and sleep (:15) keeps the two crons out of lockstep with the existing measure cron at :00, smoothing the load against the Withings 120-req/min/app cap.