Sha256: dbaf02adbcdaac8b7d36a2759ee51638ee1a834ac2fdcc109cee379a99538a48

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 Bytes

Contents

require "celsius/transformation/step"

class Celsius::PrimoUbpb::Adapter::Search::SearchResultTransformation::
  MakeFacetCreationdateHistogramFacet < Celsius::Transformation::Step

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celsius-primo_ubpb-0.1.4 lib/celsius/primo_ubpb/adapter/search/search_result_transformation/make_facet_creationdate_histogram_facet.rb
celsius-primo_ubpb-0.1.3 lib/celsius/primo_ubpb/adapter/search/search_result_transformation/make_facet_creationdate_histogram_facet.rb