-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate pagination in searcher #2119
Deprecate pagination in searcher #2119
Conversation
It shouldn't be the searcher's responsibility to also handle how pagination is happening.
@@ -9,8 +9,8 @@ def show | |||
@taxon = Spree::Taxon.find_by!(permalink: params[:id]) | |||
return unless @taxon | |||
|
|||
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true)) | |||
@products = @searcher.retrieve_products | |||
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true).reject { |k, v| ["per_page", "page"].include?(k) } ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused block argument - v. If it's necessary, use _ or _v as an argument name to indicate that it won't be used.
@@ -9,8 +9,8 @@ class ProductsController < Spree::StoreController | |||
respond_to :html | |||
|
|||
def index | |||
@searcher = build_searcher(params.merge(include_images: true)) | |||
@products = @searcher.retrieve_products | |||
@searcher = build_searcher(params.merge(include_images: true).reject { |k, v| ["per_page", "page"].include?(k) } ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused block argument - v. If it's necessary, use _ or _v as an argument name to indicate that it won't be used.
|
||
per_page = params[:per_page].to_i | ||
@properties[:per_page] = per_page > 0 ? per_page : Spree::Config[:products_per_page] | ||
@properties[:page] = (params[:page].to_i <= 0) ? 1 : params[:page].to_i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit parentheses for ternary conditions.
@@ -9,8 +9,8 @@ def show | |||
@taxon = Spree::Taxon.find_by!(permalink: params[:id]) | |||
return unless @taxon | |||
|
|||
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true)) | |||
@products = @searcher.retrieve_products | |||
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true).reject { |k, v| ["per_page", "page"].include?(k) } ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused block argument - v. If it's necessary, use _ or _v as an argument name to indicate that it won't be used.
@@ -9,8 +9,8 @@ class ProductsController < Spree::StoreController | |||
respond_to :html | |||
|
|||
def index | |||
@searcher = build_searcher(params.merge(include_images: true)) | |||
@products = @searcher.retrieve_products | |||
@searcher = build_searcher(params.merge(include_images: true).reject { |k, v| ["per_page", "page"].include?(k) } ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused block argument - v. If it's necessary, use _ or _v as an argument name to indicate that it won't be used.
|
||
per_page = params[:per_page].to_i | ||
@properties[:per_page] = per_page > 0 ? per_page : Spree::Config[:products_per_page] | ||
@properties[:page] = (params[:page].to_i <= 0) ? 1 : params[:page].to_i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit parentheses for ternary conditions.
4169eb5
to
6874572
Compare
@@ -9,8 +9,9 @@ def show | |||
@taxon = Spree::Taxon.find_by!(permalink: params[:id]) | |||
return unless @taxon | |||
|
|||
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true)) | |||
@products = @searcher.retrieve_products | |||
binding.pry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugger entry point binding.pry.
@@ -9,8 +9,9 @@ class ProductsController < Spree::StoreController | |||
respond_to :html | |||
|
|||
def index | |||
@searcher = build_searcher(params.merge(include_images: true)) | |||
@products = @searcher.retrieve_products | |||
binding.pry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugger entry point binding.pry.
@@ -9,8 +9,9 @@ def show | |||
@taxon = Spree::Taxon.find_by!(permalink: params[:id]) | |||
return unless @taxon | |||
|
|||
@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true)) | |||
@products = @searcher.retrieve_products | |||
binding.pry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugger entry point binding.pry.
@@ -9,8 +9,9 @@ class ProductsController < Spree::StoreController | |||
respond_to :html | |||
|
|||
def index | |||
@searcher = build_searcher(params.merge(include_images: true)) | |||
@products = @searcher.retrieve_products | |||
binding.pry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugger entry point binding.pry.
6874572
to
0e23f24
Compare
These two places are the only place we support the searcher on the frontend
0e23f24
to
8aa9c81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very good change. Should we add a changelog note?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great change!
Should solidus_api also receive an explicit dependency as it calls kaminari functions? |
We actually use kaminari on the frontend, backend, and api. We should explicitely add it as a dependency
8aa9c81
to
8a0e7cd
Compare
Good call hawth, added. |
@cbrunsdon You have omitted to update the home controller as well, therefore the products at frontend homepage has lost the ability to paginate. And also when performing Search, it doesn't paginate as well. I'm not sure which file need to update. Thanks. |
This deprecates doing pagination in the base searcher and instead pushes the responsibility onto the caller (in our cases the controllers).
We don't gain anything from doing the pagination inside the searcher, and it doesn't have anything to do with the core goal of it (searching).
Also throws the explicit dependencies on kaminari on frontend and backend (as they call kaminari functions).