mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 23:53:15 +01:00
fix facets attribute access
This commit is contained in:
parent
4aa0b2424b
commit
2caec3d721
2 changed files with 13 additions and 3 deletions
|
@ -6,7 +6,17 @@ 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']
|
@paper_type_facets = extract_facets('paper_types')
|
||||||
@originator_facets = @response.response['aggregations']['originators']['buckets']
|
@originator_facets = extract_facets('originators')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def extract_facets(name)
|
||||||
|
@response.
|
||||||
|
response['aggregations'][name.to_s]['buckets'].
|
||||||
|
# rewrite key => term, doc_count => count
|
||||||
|
map {|m| Hashie::Mash.new term: m['key'], count: m['doc_count'] }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ module SearchHelper
|
||||||
content_tag(:ul) do
|
content_tag(:ul) do
|
||||||
facets.each do |facet|
|
facets.each do |facet|
|
||||||
concat content_tag(:li,
|
concat content_tag(:li,
|
||||||
"#{facet['key']} (#{facet['doc_count']})",
|
"#{facet.term} (#{facet.count})",
|
||||||
class: "facet"
|
class: "facet"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue