cordova-plugin-health icon indicating copy to clipboard operation
cordova-plugin-health copied to clipboard

Parameters 'limit' and 'ascending' are ignored when querying workouts on iOS

Open kheber92 opened this issue 3 years ago • 3 comments

Hi,

It seems like the following parameters are ignored when querying data:

  • limit?: number
  • ascending?: boolean

My query looks like this ('start' and 'end' are from type Date):

this.health.query({
      startDate: start,
      endDate: end,
      ascending: false,
      limit: 3,
      dataType: 'workouts'
    })

Expected result: 3 results between startDate and endDate, in descending order.

Actual result: 10 (all) results between startDate and endDate, in ascending order.

I tried different limits (1, 3, 5, 10), it doesn't effect the result, it seems like the parameters are ignored. I always get all data between the dates set.

Furthermore, the documentation says:

Datapoints are ordered in an descending fashion (from newer to older)

Although if I skip the 'ascending' parameter, it's still ordered ascending, not descending. I simply can't change the ordering and by default it's ascending, not descending as described.

The other parameters like startDate or dataType are working perfectly, so the query itself should be fine.

kheber92 avatar Mar 01 '21 16:03 kheber92

which operating system?

dariosalvi78 avatar Mar 01 '21 18:03 dariosalvi78

which operating system?

iOS 14.4 on a real device (iPhone X).

kheber92 avatar Mar 02 '21 07:03 kheber92

it's not supported for workouts, see https://github.com/dariosalvi78/cordova-plugin-health/blob/bfe553141b2ae76175a0a74aead3339446d37aa3/src/ios/HealthKit.m#L796

any help to fix this is welcome

dariosalvi78 avatar Mar 02 '21 08:03 dariosalvi78