You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see that the returned results for getDailyStepCountSamples returns multiple objects per day. Is there a way to have it return the total for each day?
The text was updated successfully, but these errors were encountered:
not that I am aware of. I use the getDailyStepCountSamples API and then simply do the aggregation into a day with the given start/end timestamps myself. I am unsure if the API guarantees a standard interval/range for each object returned, so knowing that, it is left up to you to decide how to aggregate the data according to your domain/user requirements.
for example, your definition of what a "day" is may change if you are doing absolute timing (i.e. every time is in UTC) vs. doing day aggregations based on relative timing (i.e. in a timezone offset). I recommend always store data as UTC, and simply present it to your users in their local timezone, but the point is it is YOUR decision as the developer what constitutes a "day" and so you have to program that aggregation yourself
it's quite simply tho conceptually, in rough pseudo code for it:
// ⬇️ your specific aggregate function below// ...may be simply determining if same calendar day for exampleconstgetHealthValueKey=(value: HealthValue)=>{//... } conststeps: HealthValue[]=getDailyStepCountSamples();conststepsAggregatedByDay=steps.reduce((accum,current)=>{constkey=getKey(current);constexistingValue=accum[key];if(existingValue){existingValue.value+=current.value;// Aggregate the value for the same key}else{accum[key]={ ...current};// Create a new entry for this key}returnaccum;},{});conststepsAggregatedByDayArray=Object.values(stepsAggregatedByDay);
I see that the returned results for getDailyStepCountSamples returns multiple objects per day. Is there a way to have it return the total for each day?
The text was updated successfully, but these errors were encountered: