Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kheber92 opened this issue Mar 1, 2021 · 3 comments
Labels
bug clearly a bug that needs to be fixed

Comments

@kheber92
Copy link

kheber92 commented Mar 1, 2021

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.

@dariosalvi78
Copy link
Owner

which operating system?

@kheber92
Copy link
Author

kheber92 commented Mar 2, 2021

which operating system?

iOS 14.4 on a real device (iPhone X).

@dariosalvi78
Copy link
Owner

dariosalvi78 commented Mar 2, 2021

it's not supported for workouts, see

HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:[HKWorkoutType workoutType] predicate:workoutPredicate limit:HKObjectQueryNoLimit sortDescriptors:nil resultsHandler:^(HKSampleQuery *sampleQuery, NSArray *results, NSError *innerError) {

any help to fix this is welcome

@dariosalvi78 dariosalvi78 changed the title Parameters 'limit' and 'ascending' are ignored Parameters 'limit' and 'ascending' are ignored when querying workouts Mar 2, 2021
@dariosalvi78 dariosalvi78 added the bug clearly a bug that needs to be fixed label Jan 12, 2024
@dariosalvi78 dariosalvi78 changed the title Parameters 'limit' and 'ascending' are ignored when querying workouts Parameters 'limit' and 'ascending' are ignored when querying workouts on iOS Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug clearly a bug that needs to be fixed
Projects
None yet
Development

No branches or pull requests

2 participants