ElevationGained returns empty array
justingshreve opened this issue · 6 comments
Describe the bug
I've logged an ExerciseSession (Samsung Health and Google Fit) which includes elevation gained. It syncs but the request to readRecords for ElevationGained returns an empty array. Distance comes back and the basic activity details, but no elevation.
To Reproduce
Steps to reproduce the behavior:
- Log an exercise session activity
- Sync with Health Connect
- Sync with an app using
react-native-health-connect
- Request elevation for the exercise session
- Empty array is returned
Expected behavior
Should return an array of elevation records, like the readRecords for 'Distance' that includes inMeters, etc.
Minimal Reproducible
const rawActivities = await readRecords('ExerciseSession', {
timeRangeFilter: {
operator: 'after',
startTime: from.toISOString()
},
});
let activities = []
// for each activity additional reads are required to pull distance and elevation
for (const a of rawActivities) {
const rawDistance = await readRecords('Distance', {
timeRangeFilter: {
operator: 'between',
startTime: a.startTime,
endTime: a.endTime
}
});
const distance = rawDistance.reduce((acc, item) => {
return acc += item.distance.inMeters
}, 0)
// distance is working great and returns values here
const rawElevation = await readRecords('ElevationGained', {
timeRangeFilter: {
operator: 'between',
startTime: a.startTime,
endTime: a.endTime
}
});
// rawElevation is empty array
console.log('rawElevation', rawElevation)
const elevation = rawElevation.reduce((acc, item) => {
return acc += item.elevation.inMeters
}, 0)
activities.push({ ...a, distance, elevation })
}
Environment:
- Health Connect Version: 2.0.3
- React Native Version: "0.73.5"
- New architecture enabled: ?
- Using Expo: Prebuild(Dev Client)
Hey!
Are you seeing any errors in ADB in Android Studio or It just returns empty array? Did you try putting it in try catch and see if an exception happens?
@matinzd thanks for the response. There are no errors logged and the function successfully returns an empty array. It does not throw an error. Do you have any examples of this working?