Skip to content

4.4.0

Compare
Choose a tag to compare
@davidcelis davidcelis released this 13 Sep 20:38
· 86 commits to master since this release

api-pagination now allows developers to manually set a total_page when paginating Arrays. This is useful when paginating results from external services such as ElasticSearch or other APIs, where you are dealing with Arrays of already-paginated results as opposed to an ActiveRecord collection:

total_count = $redis.llen "ratings"
page, per_page = params.fetch(:page, 1), params.fetch(:per_page, 25)
start = (page - 1) * per_page
results = $redis.lrange "ratings", start, start + per_page

paginate results, paginate_array_options: { total_count: total_count }