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

Sorted submissions are not paginated correctly #2108

Closed
FrankApiyo opened this issue Jun 22, 2021 · 1 comment · Fixed by #2113
Closed

Sorted submissions are not paginated correctly #2108

FrankApiyo opened this issue Jun 22, 2021 · 1 comment · Fixed by #2113

Comments

@FrankApiyo
Copy link
Member

FrankApiyo commented Jun 22, 2021

Environmental Information

  • Onadata version: v2.5.7

Problem description

Submissions on data endpoint are not paginated correctly when you pass sort query parameter

Without sort query parameter:

Screenshot from 2021-06-22 12-47-08

With sort query parameter:
Screenshot from 2021-06-22 12-46-51

Expected behavior

Pagination query parameters should work the same with or without the order query parameters

@FrankApiyo FrankApiyo changed the title ordered submissions are not paginated correctly Sorted submissions are not paginated correctly Jun 22, 2021
@denniswambua denniswambua added this to the Week 26 -27 milestone Jun 25, 2021
@WinnyTroy WinnyTroy self-assigned this Jun 29, 2021
@WinnyTroy
Copy link
Contributor

WinnyTroy commented Jun 29, 2021

From testing this, I would like to note the following:

The API does successfully return paginated, sorted data (Ascending and Descending). The request you should be making should ideally be:

https://api.ona.io/api/v1/data/381370.json?page_size=3&page=1&sort={"_submission_time":-1}
https://api.ona.io/api/v1/data/381370.json?page_size=3&page=1&sort={"date_created":-1}

Sorting a specific field within the submitted data occurs successfully as detailed here, but this returns all fields within the submitted data for the form.
If your goal is to fetch paginated, sorted fields in the submitted data, pagination query params are not supported at the moment i.e page_size and page, but you could do:
https://api.ona.io/api/v1/data/381370.json?limit=10&sort={"_submission_time":-1}&fields=["_submission_time", "_id"]
The limit query param has been detailed here

I'll be adding tests to confirm the above scenerios work as expected and updating the documentation appropriately

Cc: @denniswambua ua @FrankApiyo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants