refactor facets_list helper

This commit is contained in:
Lars Henrik Mai 2015-06-22 20:58:25 +02:00 committed by Andreas Haller
parent 1cf5485356
commit 4aa0b2424b
2 changed files with 4 additions and 4 deletions

View file

@ -6,7 +6,7 @@ class SearchController < ApplicationController
@response = Paper.search(params[:q], options) @response = Paper.search(params[:q], options)
@papers = @response.page(params[:page]).results @papers = @response.page(params[:page]).results
@paper_type_facets = @response.response['aggregations']['paper_types']['buckets'].map {|h| [ h['key'], h['doc_count']] } @paper_type_facets = @response.response['aggregations']['paper_types']['buckets']
@originator_facets = @response.response['aggregations']['originators']['buckets'].map {|h| [ h['key'], h['doc_count']] } @originator_facets = @response.response['aggregations']['originators']['buckets']
end end
end end

View file

@ -2,9 +2,9 @@ module SearchHelper
def facet_list(facets) def facet_list(facets)
return unless facets.present? return unless facets.present?
content_tag(:ul) do content_tag(:ul) do
facets.each do |term, count| facets.each do |facet|
concat content_tag(:li, concat content_tag(:li,
"#{term} (#{count})", "#{facet['key']} (#{facet['doc_count']})",
class: "facet" class: "facet"
) )
end end