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

Improve pagination #33

Closed
wants to merge 5 commits into from

Conversation

puck
Copy link

@puck puck commented Oct 29, 2019

Insert total page count and previous/next links for plural collection results

Andrew Ruthven added 5 commits October 25, 2019 06:29
Collection results which require pagination now include "pages",
"next_page" and "prev_page". The later two only if there are next
or previous pages. For example:

https://10.0.19.168/REST/2.0/queues/all?per_page=5\&page=3

{
   "count" : 5,
   "pages" : 8,
   "page" : 3,
   "per_page" : 5,
   "prev_page" : "https://10.0.19.168/REST/2.0/queues/all?per_page=5&page=2",
   "next_page" : "https://10.0.19.168/REST/2.0/queues/all?per_page=5&page=4",
   "total" : 37,
   "items" : [ ... ]
}
Because we haven't applied the limits to the query yet, the call
to CountAll returns the total number of results. Therefore, using
that to limit the number of available of pages is useless.
@puck
Copy link
Author

puck commented Oct 29, 2019

This PR replaces #5 .

bestpractical-mirror pushed a commit that referenced this pull request Mar 30, 2020
Collection results which require pagination now include "pages",
"next_page" and "prev_page". The later two only if there are next
or previous pages. For example:

https://10.0.19.168/REST/2.0/queues/all?per_page=5\&page=3

{
   "count" : 5,
   "pages" : 8,
   "page" : 3,
   "per_page" : 5,
   "prev_page" : "https://10.0.19.168/REST/2.0/queues/all?per_page=5&page=2",
   "next_page" : "https://10.0.19.168/REST/2.0/queues/all?per_page=5&page=4",
   "total" : 37,
   "items" : [ ... ]
}

Don't limit the page param by a guess of the number of pages.

Because we haven't applied the limits to the query yet, the call
to CountAll returns the total number of results. Therefore, using
that to limit the number of available of pages is useless.

Based on public github PR #33
bestpractical-mirror pushed a commit that referenced this pull request Mar 30, 2020
Collection results which require pagination now include "pages",
"next_page" and "prev_page". The later two only if there are next
or previous pages. For example:

https://10.0.19.168/REST/2.0/queues/all?per_page=5\&page=3

{
   "count" : 5,
   "pages" : 8,
   "page" : 3,
   "per_page" : 5,
   "prev_page" : "https://10.0.19.168/REST/2.0/queues/all?per_page=5&page=2",
   "next_page" : "https://10.0.19.168/REST/2.0/queues/all?per_page=5&page=4",
   "total" : 37,
   "items" : [ ... ]
}

Don't limit the page param by a guess of the number of pages.

Because we haven't applied the limits to the query yet, the call
to CountAll returns the total number of results. Therefore, using
that to limit the number of available of pages is useless.

Based on public github PR #33
@sunnavy
Copy link
Member

sunnavy commented May 1, 2020

Merged and thanks!

@sunnavy sunnavy closed this May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants