flutter-plugins icon indicating copy to clipboard operation
flutter-plugins copied to clipboard

[Health ^3.4.4 ] Add ability to retrieve steps within a range and return results separated into days

Open cswkim opened this issue 2 years ago • 1 comments

Currently you can retrieve steps using getTotalStepsInInterval() which takes a range and returns a single cumulative total. What would be a nice feature is to maybe have another function which could take a range but instead of returning a single value, return an array of results by day. So something like getStepsByDayInInterval(start, end) which returns something like [{'2022-09-01': 4457, '2022-09-02': 8273}]. I know in Apple HealthKit at least there is a HKStatisticsCollection query that might allow for the returning of data in this pattern. Otherwise if you wanted to know steps for each day within a range of let's say 30 days, you would have to make 30 separate calls to getTotalStepsInInterval() which seems very expensive and inefficient.

Is this something in the roadmap or maybe a potential PR that I could tackle?

cswkim avatar Sep 14 '22 21:09 cswkim

I have attempted to make this fix based on google health connect docs in my repo

https://github.com/AngryDuckFTW/flutter-plugins

the issue is im now getting errors about time zones or something

etZoneOffset(Landroid/health/connect/datatypes/AggregationType;)Lj$/time/ZoneOffset; in class Landroid/health/connect/AggregateRecordsGroupedByDurationResponse; or its super classes (declaration of 'android.health.connect.AggregateRecordsGroupedByDurationResponse' appears in /apex/com.android.healthfitness/javalib/framework-healthfitness.jar)

Anyone is welcome to have a look and see if they can make it work, for now ive only done this on google health connect as iOS seems a more simple fix, but this android one i cant seem to make work.

This feature is seriously needed though because without it the steps functionality of this library is basically useless, if i want to request a days worth of steps by hour that 24 calls to Health connect, and after modifying this lib to not just swallow the error i have found that i was getting rate limited after requesting one days worth of steps.

Any idea if we could just get this in please, please see my fork for an idea of what i think is far better

AngryDuckFTW avatar Feb 14 '24 17:02 AngryDuckFTW