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

How to use AggregateGroupByPeriodRequest and AggregateGroupByDurationRequest? #16

Closed
nightskyhub opened this issue Apr 5, 2023 · 8 comments · Fixed by #157
Closed
Labels

Comments

@nightskyhub
Copy link

How can we aggregate steps data for day.
Let's say I want to fetch data for past 7 days and want count of total steps per day.

@matinzd
Copy link
Owner

matinzd commented Apr 5, 2023

Hi

Yes! You can find it in the documentation below:

https://matinzd.github.io/react-native-health-connect/docs/api/methods/aggregateRecord

Each record type has its own result type. You can try Steps record and see what results you'll get. If you want tota steps count for each day, you need to chunk below example into 7 different days.

Example:

aggregateRecord({
  recordType: 'Steps',
  timeRangeFilter: {
    operator: 'between',
    startTime: new Date(
      new Date().getTime() - 7 * 24 * 60 * 60 * 1000 // 7 days
    ).toISOString(),
    endTime: new Date().toISOString(),
  },
}).then((result) => {
  console.log(result.COUNT_TOTAL);
});

@matinzd matinzd added the Type: question Further information is requested label Apr 5, 2023
@matinzd
Copy link
Owner

matinzd commented Apr 5, 2023

Thanks for pointing these out. I think these were added in the recent versions and it's not supported yet. I will add those to the roadmap.

@matinzd matinzd added Type: enhancement Type: feature request New feature or request and removed Type: question Further information is requested labels Apr 5, 2023
@chganesh
Copy link

@matinzd @nightskyhub
How can we aggregate steps data for day and All vitals .
Let's say I want to fetch data for past 7 and 30 days and want count of total steps per day.

i want display all vitals and steps and burned calories sleep ...etc is is possible to display all this stuff
please help on this

thanks in advance

@cannyRamji
Copy link

Hi @matinzd, When we can expect this feature, we are facing performance issue due to this. iOS by default provide payload in 1 Hour range

#16 (comment)

@shesellsanctuary
Copy link

Hello @matinzd, Is there a plan to fulfil this feature?

@matinzd
Copy link
Owner

matinzd commented Sep 6, 2024

If someone is up for sponsoring I will dedicate some time to implement it. Otherwise you can fork the project and add it yourself.

@taisuke-j
Copy link
Contributor

@matinzd Just made a PR integrating aggregateGroupByPeriod API. Would be great if you could take a look

#157

@matinzd matinzd linked a pull request Oct 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants