Skip to content

Mobile app Sleep sync fix - fixed entry_date fix#793

Merged
CodeWithCJ merged 2 commits intomainfrom
dev
Mar 1, 2026
Merged

Mobile app Sleep sync fix - fixed entry_date fix#793
CodeWithCJ merged 2 commits intomainfrom
dev

Conversation

@CodeWithCJ
Copy link
Owner

@CodeWithCJ CodeWithCJ commented Mar 1, 2026

Mobile app Sleep sync fix - fixed entry_date to use wakeup time isntead of start time to align with mobile health apps

Description

Provide a brief summary of your changes.

Related Issue

PR type [ ] Issue [ ] New Feature [ ] Documentation
Linked Issue: #

Checklist

Please check all that apply:

  • Alignment: I have raised a GitHub issue and it was reviewed/approved by maintainers (required for new features).
  • Tests: I have included automated tests for my changes.
  • Screenshots: I have attached "Before" vs "After" screenshots below (required for UI changes).
  • Quality: I have run npm run lint and npm run format (especially for Frontend).
  • Translations: I have only updated the English (en) translation file (if applicable).
  • Architecture: My code follows the existing architecture standards.
  • Database Security: I have updated rls_policies.sql for any new user-specific tables.
  • Integrity: I certify this is my own work, free of malicious code(phishing, malware, etc.)
  • License: I agree to the License terms.

Screenshots (if applicable)

Before

[Insert screenshot/GIF here]

After

[Insert screenshot/GIF here]

…ad of start time to aling with mobile health apps
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 addresses an inconsistency in how sleep session entry dates are recorded across different health data sources. By modifying the logic to use the wake-up or end time for the entry_date, the changes ensure that sleep data is accurately aligned with how mobile health applications typically represent sleep cycles, improving data integrity and consistency.

Highlights

  • Health Connect Sleep Data: Corrected the recordDate calculation for sleep sessions in Health Connect data transformation to use the endTime instead of the startTime, aligning with mobile health app conventions.
  • HealthKit Sleep Data: Adjusted the entry_date calculation for aggregated HealthKit sleep sessions to utilize the wake_time instead of the bedtime, ensuring accurate date assignment for sleep records.
Changelog
  • SparkyFitnessMobile/src/services/healthconnect/dataTransformation.ts
    • Modified recordDate assignment to use rec.endTime instead of rec.startTime for sleep sessions.
  • SparkyFitnessMobile/src/services/healthkit/dataAggregation.ts
    • Updated entry_date calculation to use session.wake_time instead of session.bedtime for aggregated sleep sessions.
Activity
  • The pull request was opened by CodeWithCJ.
  • No human activity (comments, reviews) has occurred on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@CodeWithCJ CodeWithCJ changed the title Mobile app Sleep sync fix - fixed entry_date to use wakeup time isnte… Mobile app Sleep sync fix - fixed entry_date fix Mar 1, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the logic for determining the entry_date for sleep sessions from both Health Connect (Android) and HealthKit (iOS). The entry_date is now correctly based on the endTime (wake-up time) of the sleep session, rather than the startTime. This aligns the behavior with common conventions in health apps.

My main feedback is regarding the unit tests. The changes are not reflected in the test suite:

  • The tests for HealthKit sleep aggregation will now fail as they still expect the entry_date to be based on bedtime.
  • The tests for Health Connect sleep transformation are missing assertions to verify the correctness of the entry_date.

It is critical to update the tests to cover this new logic to prevent regressions and ensure the feature works as expected.

@CodeWithCJ CodeWithCJ merged commit 67f8d47 into main Mar 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant