lib/blacklight/solr/search_builder_behavior.rb in blacklight-5.17.2 vs lib/blacklight/solr/search_builder_behavior.rb in blacklight-5.18.0
- old
+ new
@@ -137,14 +137,12 @@
facet.solr_params.each do |k, v|
solr_parameters[:"f.#{facet.field}.#{k}"] = v
end
end
- # Support facet paging and 'more'
- # links, by sending a facet.limit one more than what we
- # want to page at, according to configured facet limits.
- solr_parameters[:"f.#{facet.field}.facet.limit"] = (facet_limit_for(field_name) + 1) if facet_limit_for(field_name)
+ limit = facet_limit_with_pagination(field_name)
+ solr_parameters[:"f.#{facet.field}.facet.limit"] = limit if limit
end
end
def add_solr_fields_to_query solr_parameters
blacklight_config.show_fields.select(&method(:should_add_field_to_request?)).each do |field_name, field|
@@ -247,9 +245,25 @@
if facet.limit
facet.limit == true ? blacklight_config.default_facet_limit : facet.limit
end
end
+
+ # Support facet paging and 'more'
+ # links, by sending a facet.limit one more than what we
+ # want to page at, according to configured facet limits.
+ def facet_limit_with_pagination(field_name)
+ limit = facet_limit_for(field_name)
+
+ return if limit.nil?
+
+ if limit > 0
+ limit + 1
+ else
+ limit
+ end
+ end
+
##
# A helper method used for generating solr LocalParams, put quotes
# around the term unless it's a bare-word. Escape internal quotes
# if needed.