Pagination & larger collection sizes#2
Merged
cohesiveneal merged 1 commit intopenseo:masterfrom Jan 17, 2019
Merged
Conversation
… collection sizes
phoet
approved these changes
Jan 16, 2019
| json = get("/collections/#{collection_id}/items", params: {limit: limit}) | ||
| json['items'] | ||
| fetched_items = [] | ||
| num_pages = (limit.to_f / 100.0).ceil |
| num_pages = (limit.to_f / 100.0).ceil | ||
| per_page = limit > 100 ? 100 : limit | ||
|
|
||
| num_pages.times do |i| |
Contributor
There was a problem hiding this comment.
i like this pattern to avoid a while loop 👍
Contributor
|
thank you @cohesiveneal ! would you be interested in becoming a maintainer? it's always nice to more people who are able to contribute. |
Contributor
Author
|
hey @phoet - sure thing, happy to! thanks! |
Contributor
|
@cohesiveneal hello and welcome dear collaborator! feel free to merge this PR yourself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Webflow updated their API to allow for limit & offset parameters on the /collection/ID/items API call. This commit adds a #paginate_items method and refactors Client#items to fetch larger sets (using the #paginate_items method).