Fix Healthspan activity and HealthKit steps - #1188
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Automated Checks (advisory, non-blocking)✅ All checks passed. Surmado Code Review — Free tier limit reachedYou've used all 10 free reviews this month. Deterministic checks (secrets, model strings) still ran above. Upgrade to the Paid plan for 100 reviews/month + $15 per additional 100: https://app.surmado.com/checkout?plan=pr_review_starter Or wait until your next monthly window for 10 more free reviews. Surmado Code Review (v1.2-mt) |
|
Warning Review limit reached
More reviews will be available in 45 minutes and 47 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Storybook previews for This comment updates automatically on each PR push. |
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: The changes fix two specific, well-documented bugs with targeted logic updates, add regression tests, and include a production incident analysis, presenting low risk as they are isolated to HealthKit sync window alignment and Healthspan scoring floor logic without altering core infrastructure...
Re-trigger cubic
Mobile PreviewScan to open on device:
To test on device:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses a production issue where (1) HealthKit incremental sync could overwrite full-day step totals with partial-day values and (2) Healthspan aerobic activity could undercount when HR/power-derived zone minutes are missing or low. It adjusts the mobile HealthKit sync window to start at the local day boundary and updates server-side Healthspan aggregation to floor aerobic minutes using device-reported weekly exercise minutes, with regression tests and an incident write-up.
Changes:
- Mobile: Start incremental HealthKit daily-statistics queries from the local calendar-day boundary (instead of a rolling 24h window).
- Server: Add a Postgres query for weekly
exercise_minutesfromfitness.v_daily_metricsand use it as a floor for weekly aerobic minutes when HR-zone minutes undercount. - Quality/docs: Add regression tests for both behaviors and document the incident analysis.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/server/src/routers/healthspan-query.ts | Adds weekly exercise-minute aggregation and uses it as an aerobic-minutes floor in Healthspan raw data. |
| packages/server/src/routers/healthspan.test.ts | Updates router/unit tests to account for the additional DB query and adds coverage for the new activity-floor behavior. |
| packages/server/src/routers/healthspan-query.test.ts | Adjusts raw-data tests for the additional DB call. |
| packages/mobile/lib/health-kit-sync.ts | Changes incremental sync start date to local midnight of the lookback window. |
| packages/mobile/lib/health-kit-sync.test.ts | Adds regression test for day-boundary incremental sync behavior. |
| docs/production-incident-baseline.md | Records incident symptoms, root cause, mitigation, and follow-ups. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Auto-approved: The changes are targeted bug fixes for undercounted HealthKit steps and Healthspan aerobic minutes, with thorough regression tests and no risky refactors or critical-path modifications.
Re-trigger cubic
|
Review app is ready: This environment runs on a dedicated Hetzner server for PR #1188 and updates on each push. |
Fixes HealthKit incremental sync to request daily quantity samples from the local day boundary instead of a rolling 24-hour window, preventing partial step totals from replacing full-day values. Updates Healthspan scoring to use weekly exercise minutes from daily metrics as the aerobic activity floor when heart-rate zone minutes undercount activity. Adds mobile and server regressions for the step sync window and Healthspan activity score behavior, and records the production incident analysis in docs/production-incident-baseline.md. Validation: pnpm lint; pnpm test:changed; pnpm tsc --noEmit; cd packages/server && pnpm tsc --noEmit; cd packages/web && pnpm tsc --noEmit.
Summary by cubic
Fixes undercounted steps and aerobic minutes by syncing HealthKit daily stats from the local day boundary and using device-reported weekly exercise minutes as a floor. Bounds all Healthspan reads to the selected date window and the user's access window.
fitness.v_daily_metricsas the aerobic floor when zone minutes are lower or missing.Written for commit cbe1a9b. Summary will update on new commits. Review in cubic