react-native-google-fit icon indicating copy to clipboard operation
react-native-google-fit copied to clipboard

basalCalculation do not work correctly in getDailyCalorieSamples

Open Innokentiy213 opened this issue 3 years ago • 7 comments

i want disable basal calculation and get only active burned calories, but regardless of the passed value(true, false, null, string value, undefined), it returns with basal calories "react-native": "^0.64.0", "react-native-google-fit": "^0.18.0", code: // const options = { startDate: startDateCals.toISOString(), endDate: new Date(), basalCalculation: false, bucketUnit: BucketUnit.DAY, bucketInterval: 1 } GoogleFit.getDailyCalorieSamples(options).then(res => { setGoogleCals(res); }).catch(err => console.log(err)); //

Innokentiy213 avatar Dec 04 '21 09:12 Innokentiy213

please supply a example with expect value and incorrect value you receive.

aboveyunhai avatar Dec 06 '21 18:12 aboveyunhai

Снимок экрана 2021-12-09 в 17 09 24

Innokentiy213 avatar Dec 09 '21 08:12 Innokentiy213

@aboveyunhai @StasDoskalenko I got the same error, what should I do?

alexbaishs avatar Jan 10 '22 06:01 alexbaishs

@alexbaishs https://github.com/StasDoskalenko/react-native-google-fit/blob/291b18a245c88e86c1b212ec8c25594764cca21a/android/src/main/java/com/reactnative/googlefit/CalorieHistory.java#L158-L166

This is the exact place where basal is calculated (which is not implemented by me), and I'm not exactly sure how the correct value/formula will be, you can twist this part of codes around in dev to check where it's the problem based on your data set.

I will come back later to fix it later if nobody come up with the solution, but currently I'm busy with some real life events.

aboveyunhai avatar Jan 10 '22 19:01 aboveyunhai

?Please fix this bug

alexbaishs avatar Mar 17 '22 06:03 alexbaishs

It looks like when basalCalculation is true, the average BMR is subtracted from the total calorie value. I may be misunderstanding here, but I think the result of that subtraction is active calories. In other words, if you want active calories, I think you set basalCalculation to true (or omit it since that's the default).

EDIT: I'm not so sure anymore. Reading through my own data for getDailyCalorieSamples(), I'm getting calorie values of 65 for hours of the day that I know was not active.

klcantrellsep avatar Mar 29 '22 01:03 klcantrellsep

It looks like when basalCalculation is true, the average BMR is subtracted from the total calorie value. I may be misunderstanding here, but I think the result of that subtraction is active calories. In other words, if you want active calories, I think you set basalCalculation to true (or omit it since that's the default).

EDIT: I'm not so sure anymore. Reading through my own data for getDailyCalorieSamples(), I'm getting calorie values of 65 for hours of the day that I know was not active.

I am looking at the basalCalculation now, if the calculation works out as expect eventually, I will deprecate this field to remove the confusion, and use something like includeBmrAvg instead. The current field, as you claimed, work the exact opposite way of the variable naming.

aboveyunhai avatar Apr 25 '22 23:04 aboveyunhai