Repository navigation
fix(health-data): apply default units for HealthConnect sync (fixes #567) - #621
Conversation
…es not show N/A (CodeWithCJ#567) - Use payload unit when present, else resolve from DEFAULT_UNITS_BY_HEALTH_TYPE - Ensures custom measurement categories get a proper measurement_type for heart rate, calories, distance, sleep, etc. - Add tests for default and payload unit behavior
Summary of ChangesHello @JosephDoUrden, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where health data synced from clients, particularly HealthConnect, would display 'N/A' for units in the web UI and generate incorrect graphs due to the backend not properly handling or defaulting measurement units. The changes introduce a robust system to intelligently assign units, either by utilizing those provided in the incoming data or by applying predefined defaults for common health metrics, thereby ensuring data integrity and accurate visualization. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of missing units for health data from clients like HealthConnect by introducing a default unit mapping. This is a solid improvement that will enhance the user experience by preventing "N/A" units in the UI. The changes are well-contained, and the addition of new tests is commendable. I have a few suggestions to improve consistency in the new unit map and enhance code readability.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rocessHealthData function
|
Thanks, happy to take another issue @CodeWithCJ |
Summary
Fixes #567: HealthConnect (and other client) sync was creating custom measurement categories with
measurement_type = 'N/A'because the backend did not use theunitfield from the payload and had no defaults. The web UI then showed "N/A" for those metrics and graphs were wrong.Changes
processHealthData, when handling scalar health data as custom measurements, the category'smeasurement_typeis now taken fromdataEntry.unit(ordataEntry.measurementType) when present; otherwise a default is applied from a newDEFAULT_UNITS_BY_HEALTH_TYPEmap (e.g. heart_rate → bpm, TotalCaloriesBurned → kcal, distance → m), aligned with the mobile HealthMetrics.measurementService.healthDataUnits.test.jsto assert default units when unit is missing and that payload unit is used when provided.Testing
npx jest tests/measurementService.healthDataUnits.test.js(withSPARKY_FITNESS_API_ENCRYPTION_KEYset) — 4 tests pass.Notes
measurement_type = 'N/A'are unchanged; users can edit the category in Settings to set the unit, or re-sync after deleting those entries if desired. New syncs will get the correct default.