fix(mobile): sync Health Connect/HealthKit hydration to water intake#1663
Conversation
Hydration was sent as type 'hydration' in liters, which the server has no case for, so it fell through to the default branch and was stored as a custom measurement named "hydration" instead of water intake. Map the hydration metric to the server's water-intake sync path: - HealthMetrics: type 'hydration' -> 'water', unit 'L' -> 'ml', and add aggregationStrategy 'sum' so multiple same-day drinks are summed into one daily total (upsertWaterData overwrites per (date, source), so unsummed records would otherwise overwrite each other). - Android + iOS transformers: convert volume.inLiters to integer ml. Now routes through case 'water' -> upsertWaterData -> water_intake table, matching how Garmin/Fitbit/Apple Health water already syncs. Containers are untouched (manual-logging only). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR Validation ResultsChange Detection
|
There was a problem hiding this comment.
Code Review
This pull request updates the hydration tracking functionality to use milliliters (ml) instead of liters (L) and maps the record type to 'water' with a 'sum' aggregation strategy. This includes updating the data transformers for both Health Connect and HealthKit to convert liters to milliliters, as well as updating corresponding tests and adding a new test for daily aggregation. The reviewer suggests adding defensive checks in both data transformers to ensure that the converted milliliter value is positive and non-zero before returning it, preventing invalid or empty records from being sent to the server.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@apedley could you review this once. |
|
Looks good! |
Tip
Help us review and merge your PR faster!
Please ensure you have completed the Checklist below.
For Frontend changes, please run
pnpm run validateto check for any errors.PRs that include tests and clear screenshots are highly preferred!
Note: AI-generated descriptions must be manually edited for conciseness. Do not paste raw AI summaries.
Description
What problem does this PR solve?
(Keep it concise. 1–2 sentences.)
Hydration was sent as type 'hydration' in liters, which the server has no case for, so it fell through to the default branch and was stored as a custom measurement named "hydration" instead of water intake.
Map the hydration metric to the server's water-intake sync path:
Now routes through case 'water' -> upsertWaterData -> water_intake table, matching how Garmin/Fitbit/Apple Health water already syncs. Containers are untouched (manual-logging only).
How did you implement the solution?
(Brief technical approach.)
Linked Issue: Closes # #1486
How to Test
...PR Type
Checklist
All PRs:
New features only:
Frontend changes (
SparkyFitnessFrontend/):pnpm run validateand it passes.en) translation file.Backend changes (
SparkyFitnessServer/):rls_policies.sqlfor any new user-specific tables.UI changes (components, screens, pages):
Mobile changes (
SparkyFitnessMobile/):Screenshots
Click to expand
Before
After
Notes for Reviewers