-
Hi, Trying to figure out how to use pagy with Algolia Ruby client. Not particularly hard, here's the approach: @records = MyModel.search(params[:query])
count = @records.raw_answer['nbHits']
page = @records.raw_answer['page']
limit = @records.raw_answer['hitsPerPage']
@pagy = Pagy.new(count: count, page: page, limit: limit) Except Algolia provides page number as zero-based. This causes pagy to throw an I can hack it to just add 1 or subtract 1 in the code above, but wondering if there's a way to allow pagy to use zero-based count. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
AFAIK the pagination business is conventionally all about pages, not page-offset, so no, there's no native support for that. It looks like you mean that the API provides a page-offset, not a page number.... interestingly there are a few widgets for pagination that actually show the one-based page number in the UI. (https://www.algolia.com/developers/code-exchange/pagination-widget/)... Maybe that's the official way of doing it? Maybe a pagy extra would be simple to write. |
Beta Was this translation helpful? Give feedback.
AFAIK the pagination business is conventionally all about pages, not page-offset, so no, there's no native support for that.
It looks like you mean that the API provides a page-offset, not a page number.... interestingly there are a few widgets for pagination that actually show the one-based page number in the UI. (https://www.algolia.com/developers/code-exchange/pagination-widget/)...
Maybe that's the official way of doing it? Maybe a pagy extra would be simple to write.