Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health Connect: Missing Step Data When Start Date Does Not Align with Midnight (00:00 hrs) Using Samsung Health #185

Open
devEbaas opened this issue Dec 17, 2024 · 2 comments

Comments

@devEbaas
Copy link

devEbaas commented Dec 17, 2024

Describe the bug

Issue Description:
When querying step data in Health Connect using Samsung Health, if the startDate does not begin at the start of the day (00:00 hrs), no step values are returned for that date.

For example:
If the startDate is {2024-09-08T00:00:00Z} (ISO format for today’s start) and the endDate is {2024-09-08T23:59:59Z}, step records are returned as expected..
However, if the startDate is {2024-09-08T04:00:00Z} (4 hours after today’s start) and the endDate is {2024-09-08T23:59:59Z}, no step records are returned, even for the rest of the day and the records always returns empty Array.
Question:
Is this behavior normal when querying step data from Samsung Health via Health Connect? Should Health Connect provide step data for the remaining part of the day even if the startDate is not exactly at 00:00 hrs?

To Reproduce

Create Two Queries for Step Data:
-> Query 1: Set the startDate to the beginning of the day (00:00 hrs) and the endDate to the end of the day (23:59 hrs).
-> Expected: Step data for the entire day is returned.

Query 2: Set the startDate to 4 hours after the start of the day (e.g., 04:00 hrs) and the endDate to the end of the day (23:59 hrs).
->Expected: Step data from 04:00 hrs to the end of the day is returned.
->Observed: No step data is returned for the time range when the startDate is not 00:00 hrs.

Expected behavior

When querying step data in Health Connect using Samsung Health, if the startDate is set to any time within the day (e.g., 04:00 hrs) and the endDate is the end of the day (e.g., 23:59:59 hrs), Health Connect should return step records for the remaining part of the day (from the startDate to the endDate), even if the startDate does not begin at midnight (00:00 hrs).
This ensures that partial-day queries provide accurate step counts for the specified time range.

Minimal Reproducible

const { records } = await readRecords('Steps', {
        timeRangeFilter: {
          operator: 'between',
          startTime: dayjs().toISOString(), //not the start of the day
          endTime: dayjs().endOf('day').toISOString(),
        },
      });

Environment:

  • Health Connect Version: 3.2.1
  • React Native Version: 0.73.6
  • New architecture enabled: No
  • Using Expo: No
  • Android API Level: e.g API 34 (Android 14)
@matinzd
Copy link
Owner

matinzd commented Dec 23, 2024

Have you tried setting zoneOffset when reading the records?

@devEbaas
Copy link
Author

devEbaas commented Dec 23, 2024

I have not added the zoneOffset to my queries to Health Connect. However, I have another function that starts exactly at 00:00 hrs, which for me would be 23/12/2024 00:00 hrs, and in ISO UTC format, it would be 2024-12-23T06:00:00.000Z. This function retrieves the data without any issues. Here is the function that correctly fetches the steps:
readRecords('Steps', {
timeRangeFilter: {
operator: 'between',
startTime: dayjs().startOf('day').toISOString(), // 2024-12-23T06:00:00.000Z
endTime: dayjs().endOf('day').toISOString(),
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants