mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Update products_renderer for pagy pagination
This commit is contained in:
committed by
Matt-Yorkley
parent
4187380225
commit
6bd28bcad8
@@ -3,6 +3,8 @@
|
||||
require 'open_food_network/scope_product_to_hub'
|
||||
|
||||
class ProductsRenderer
|
||||
include Pagy::Backend
|
||||
|
||||
class NoProducts < RuntimeError; end
|
||||
DEFAULT_PER_PAGE = 10
|
||||
|
||||
@@ -50,9 +52,15 @@ class ProductsRenderer
|
||||
end
|
||||
|
||||
def filter_and_paginate(query)
|
||||
query.
|
||||
ransack(args[:q]).
|
||||
result
|
||||
results = query.ransack(args[:q]).result
|
||||
|
||||
_pagy, paginated_results = pagy(
|
||||
results,
|
||||
page: args[:page] || 1,
|
||||
items: args[:per_page] || DEFAULT_PER_PAGE
|
||||
)
|
||||
|
||||
paginated_results
|
||||
end
|
||||
|
||||
def distributed_products
|
||||
|
||||
Reference in New Issue
Block a user