feat: global health data sync and comprehensive UI refresh fixes#718
feat: global health data sync and comprehensive UI refresh fixes#718CodeWithCJ merged 7 commits intomainfrom
Conversation
Summary of ChangesHello @CodeWithCJ, 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 significantly enhances the application's data synchronization capabilities and user experience. It introduces a convenient global "Sync All" feature, allowing users to refresh data from all connected external providers with a single click. Concurrently, it addresses UI data freshness issues, ensuring that newly synced information is immediately reflected without requiring manual page reloads. Furthermore, the backend has been fortified to handle incomplete data from external APIs more gracefully, improving overall system reliability. 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 introduces a new global synchronization feature, adding a GlobalSyncButton component to the main layout that allows users to manually sync data from active external providers like Strava, Fitbit, Polar, Withings, Garmin, and Hevy. New translation keys for sync-related messages have been added, and react-query settings were adjusted to reduce staleTime and enable refetching on window focus, reconnect, and mount for better responsiveness. A new useSyncAll hook was created to orchestrate the synchronization process, displaying toast notifications for success or failure. Additionally, the handling of calories_burned in exercise entries was improved across Fitbit, Hevy, and Strava data processors, ensuring a default value of 0 to prevent null issues. Review comments suggest refactoring the duplicated query invalidation logic into a shared hook, creating a shared constant for the list of manual sync providers, and updating the DataProvider interface to properly type the has_token property instead of using as unknown as.
SparkyFitnessFrontend/src/hooks/Integrations/useIntegrations.ts
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a global sync feature and improves UI data freshness by adjusting react-query settings and centralizing invalidation logic. It also hardens backend data processing for Fitbit, Hevy, and Strava to prevent NOT NULL violations. The changes are well-structured, and the new useDiaryInvalidation hook and GlobalSyncButton component enhance maintainability and user experience. The updates to the backend data processors correctly handle missing values, which is a good improvement for data integrity.
Summary
This PR addresses synchronization reliability, improves UI data freshness, and introduces a new global "Sync All" feature. It resolves the issue where the Diary page required a manual browser refresh to display newly synced data and hardens the backend against integration data errors.
Changes
New Feature: Added a "Sync All" button to the application header. It automatically detects all active manual-sync providers (Strava, Fitbit, Polar, Withings, Garmin, Hevy) and triggers them sequentially.
Refactoring: Extracted sync orchestration and cache invalidation logic into a new shared
useSyncAll
hook.
Internationalization: Added English translation keys for the new global sync UI and notifications.
2. Cache & UI Freshness (Frontend)
Global Config Fix: Updated
App.tsx
to enable refetchOnMount and refetchOnWindowFocus in the global QueryClient defaults. This ensures that invalidated/stale data is actually refetched when the user navigates back to the Diary.
Unified Invalidation: Implemented a robust invalidateSyncData helper that triggers a refresh for Exercises, Daily Progress (Calories/Steps), Measurements (Weight), and Sleep data.
Integration Hardening: Applied the invalidation logic to all manual sync points in
ExternalProviderSettings
and all OAuth linking hooks in
useIntegrations.ts
.
3. Integration Robustness (Backend)
Model Hardening: Updated exerciseEntry.js to include default values (e.g., 0 for calories_burned), preventing NOT NULL violations if an external API sends incomplete data.
Processor Improvements: Hardened Strava, Fitbit, and Hevy data processors to handle specific API quirks and ensure data integrity during synchronization.
Verification Results
UI Refresh: Confirmed that data updates immediately on the Diary page after a "Sync All" or manual sync completes, with no browser refresh required.
"Sync All" Button: Verified the sequential triggering of multiple providers and the summary toast notification.
Database Safety: Verified that activities with missing fields no longer cause server-side crashes during ingestion.