From 4aa0b2424bd9b552f9bbc5d3ceb9a51b9919a5dd Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Mon, 22 Jun 2015 20:58:25 +0200 Subject: [PATCH] refactor facets_list helper --- app/controllers/search_controller.rb | 4 ++-- app/helpers/search_helper.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 14ba250..ba80544 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -6,7 +6,7 @@ class SearchController < ApplicationController @response = Paper.search(params[:q], options) @papers = @response.page(params[:page]).results - @paper_type_facets = @response.response['aggregations']['paper_types']['buckets'].map {|h| [ h['key'], h['doc_count']] } - @originator_facets = @response.response['aggregations']['originators']['buckets'].map {|h| [ h['key'], h['doc_count']] } + @paper_type_facets = @response.response['aggregations']['paper_types']['buckets'] + @originator_facets = @response.response['aggregations']['originators']['buckets'] end end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index d1c5945..3491258 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -2,9 +2,9 @@ module SearchHelper def facet_list(facets) return unless facets.present? content_tag(:ul) do - facets.each do |term, count| + facets.each do |facet| concat content_tag(:li, - "#{term} (#{count})", + "#{facet['key']} (#{facet['doc_count']})", class: "facet" ) end