dariosalvi78 / cordova-plugin-health

Cordova plugin for the HealthKit and Google Fit frameworks
MIT License
175 stars 126 forks source link

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

Open kheber92 opened 3 years ago

kheber92 commented 3 years ago

Hi,

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

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.

dariosalvi78 commented 3 years ago

which operating system?

kheber92 commented 3 years ago

which operating system?

iOS 14.4 on a real device (iPhone X).

dariosalvi78 commented 3 years ago

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