Module: Europeana::Blacklight::SearchBuilder::FacetPagination

Extended by:
ActiveSupport::Concern
Included in:
Europeana::Blacklight::SearchBuilder
Defined in:
lib/europeana/blacklight/search_builder/facet_pagination.rb

Overview

Search builder methods for facet pagination

Instance Method Summary collapse

Instance Method Details

#add_facet_paging_to_api(api_parameters) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/europeana/blacklight/search_builder/facet_pagination.rb', line 13

def add_facet_paging_to_api(api_parameters)
  return unless facet.present?

  facet_config = blacklight_config.facet_fields[facet]

  limit = if scope.respond_to?(:facet_list_limit)
      scope.facet_list_limit.to_s.to_i
    elsif api_parameters['facet.limit']
      api_parameters['facet.limit'].to_i
    else
      20
    end

  offset = (blacklight_params.fetch(blacklight_config.facet_paginator_class.request_keys[:page], 1).to_i - 1) * (limit)

  # Need to set as f.facet_field.facet.* to make sure we
  # override any field-specific default in the solr request handler.
  api_parameters[:"f.#{facet}.facet.limit"] = limit
  api_parameters[:"f.#{facet}.facet.offset"] = offset
  api_parameters[:rows] = 0
end