Class: BlacklightRangeLimit::FacetFieldPresenter
- Inherits:
-
Blacklight::FacetFieldPresenter
- Object
- Blacklight::FacetFieldPresenter
- BlacklightRangeLimit::FacetFieldPresenter
- Defined in:
- app/presenters/blacklight_range_limit/facet_field_presenter.rb
Instance Method Summary collapse
- #max ⇒ Object
- #min ⇒ Object
- #missing_facet_item ⇒ Object
- #missing_selected? ⇒ Boolean
- #paginator ⇒ Object
- #range_config ⇒ Object
- #range_queries ⇒ Object
- #selected_range ⇒ Object
- #selected_range_facet_item ⇒ Object
Instance Method Details
#max ⇒ Object
30 31 32 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 30 def max range_results_endpoint(:max) end |
#min ⇒ Object
26 27 28 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 26 def min range_results_endpoint(:min) end |
#missing_facet_item ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 44 def missing_facet_item return unless missing.positive? Blacklight::Solr::Response::Facets::FacetItem.new( value: Blacklight::SearchState::FilterField::MISSING, hits: missing ) end |
#missing_selected? ⇒ Boolean
53 54 55 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 53 def missing_selected? selected_range == Blacklight::SearchState::FilterField::MISSING end |
#paginator ⇒ Object
22 23 24 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 22 def paginator nil end |
#range_config ⇒ Object
57 58 59 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 57 def range_config @facet_field.range_config end |
#range_queries ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 8 def range_queries return [] unless response.dig('facet_counts', 'facet_queries') range_regex = /#{facet_field.field}: *\[ *(-?\d+) *TO *(-?\d+) *\]/ array = response.dig('facet_counts', 'facet_queries').map do |query, count| if (match = range_regex.match(query)) Blacklight::Solr::Response::Facets::FacetItem.new(value: match[1].to_i..match[2].to_i, hits: count) end end array.compact.sort_by { |item| item.value.first } end |
#selected_range ⇒ Object
34 35 36 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 34 def selected_range search_state.filter(key).values.first end |
#selected_range_facet_item ⇒ Object
38 39 40 41 42 |
# File 'app/presenters/blacklight_range_limit/facet_field_presenter.rb', line 38 def selected_range_facet_item return unless selected_range Blacklight::Solr::Response::Facets::FacetItem.new(value: selected_range, hits: response.total) end |