class Celsius::PrimoUbpb::Adapter::Search::SearchResultTransformation::MakeFacetCreationdateHistogramFacet

Public Instance Methods

call() click to toggle source
# File lib/celsius/primo_ubpb/adapter/search/search_result_transformation/make_facet_creationdate_histogram_facet.rb, line 6
def call
  if facet_creationdate = target["facets"]["facet_creationdate"]
    facet_creationdate["_type"] = "histogram"
    facet_creationdate["entries"] = facet_creationdate["terms"]
    facet_creationdate.delete("terms")
    facet_creationdate["entries"].each do |entry|
      entry["key"] = entry["term"]
      entry.delete("term")
    end

    # histogram facet should be sorted
    facet_creationdate["entries"].sort! { |a, b| a["key"] <=> b["key"] }
  end
end