lib/blacklight_range_limit/segment_calculation.rb
# Calculates segment facets within a given start and end on a given
# field, returns request params to be added on to what's sent to
# solr to get the calculated facet segments.
# Assumes solr_field is an integer, as range endpoint will be found
# by subtracting one from subsequent boundary.
#
# Changes solr_params passed in.
Calculates segment facets within a given start and end on a given
field, returns request params to be added on to what's sent to
solr to get the calculated facet segments.
Assumes solr_field is an integer, as range endpoint will be found
by subtracting one from subsequent boundary.

Changes solr_params passed in.
Calculates segment facets within a given start and end on a given field returns request params to be added on to what ' s sent to solr to get the calculated facet segments . Assumes solr_field is an integer as range endpoint will be found by subtracting one from subsequent boundary . Changes solr_params passed in .
def add_range_segments_to_solr!(solr_params, facet_field, min, max)
      raise InvalidRange, "The min date must be before the max date" if min > max
      field_config = blacklight_config.facet_fields[facet_field.to_s]
      return solr_params unless field_config
      range_config = BlacklightRangeLimit.range_config(blacklight_config, facet_field)
      solr_params[:"facet.query"] ||= []
      boundaries = boundaries_for_range_facets(min, max, (range_config[:num_segments] || 10) )
      0.upto(boundaries.length - 2) do |index|
        first = boundaries[index]
        last =  boundaries[index+1].to_i - 1
        solr_params[:"facet.query"] << "#{field_config.field}:[#{first} TO #{last}]"
      end
      solr_params
    end
def add_range_segments_to_solr! ( solr_params , facet_field , min , max ) raise InvalidRange , "The min date must be before the max date" if min > max field_config = blacklight_config . facet_fields [ facet_field . to_s ] return solr_params unless field_config range_config = BlacklightRangeLimit . range_config ( blacklight_config , facet_field ) solr_params [ :" facet.query " ] ||= [ ] boundaries = boundaries_for_range_facets ( min , max , ( range_config [ :num_segments ] || 10 ) ) 0 . upto ( boundaries . length - 2 ) do | index | first = boundaries [ index ] last = boundaries [ index + 1 ] . to_i - 1 solr_params [ :" facet.query " ] << "#{field_config.field}:[#{first} TO #{last}]" end solr_params end
Calculates segment facets within a given start and end on a given
field, returns request params to be added on to what's sent to
solr to get the calculated facet segments.
Calculates segment facets within a given start and end on a given field returns request params to be added on to what ' s sent to solr to get the calculated facet segments .
# Now make the boundaries into actual filter.queries.
solr_params
facet_field
min
max