Skip to content

Pagination & larger collection sizes#2

Merged
cohesiveneal merged 1 commit into
penseo:masterfrom
cohesivecc:master
Jan 17, 2019
Merged

Pagination & larger collection sizes#2
cohesiveneal merged 1 commit into
penseo:masterfrom
cohesivecc:master

Conversation

@cohesiveneal

Copy link
Copy Markdown
Contributor

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).

@phoet phoet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 thx!

Comment thread lib/webflow/client.rb
json = get("/collections/#{collection_id}/items", params: {limit: limit})
json['items']
fetched_items = []
num_pages = (limit.to_f / 100.0).ceil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know number.fdiv ?

Comment thread lib/webflow/client.rb
num_pages = (limit.to_f / 100.0).ceil
per_page = limit > 100 ? 100 : limit

num_pages.times do |i|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this pattern to avoid a while loop 👍

@phoet

phoet commented Jan 16, 2019

Copy link
Copy Markdown
Contributor

thank you @cohesiveneal ! would you be interested in becoming a maintainer? it's always nice to more people who are able to contribute.

@cohesiveneal

Copy link
Copy Markdown
Contributor Author

hey @phoet - sure thing, happy to! thanks!

@phoet

phoet commented Jan 17, 2019

Copy link
Copy Markdown
Contributor

@cohesiveneal hello and welcome dear collaborator! feel free to merge this PR yourself.

@cohesiveneal cohesiveneal merged commit 58a4d64 into penseo:master Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants