mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 15:43:14 +01:00
add filter for originator
This commit is contained in:
parent
41ed4a9674
commit
1cf5485356
2 changed files with 5 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
|||
class SearchController < ApplicationController
|
||||
def index
|
||||
@paper_type = params[:paper_type]
|
||||
options = params.slice(:paper_type)
|
||||
@originator = params[:originator]
|
||||
options = params.slice(:paper_type, :originator)
|
||||
|
||||
@response = Paper.search(params[:q], options)
|
||||
@papers = @response.page(params[:page]).results
|
||||
|
|
|
@ -65,7 +65,9 @@ class Paper < ActiveRecord::Base
|
|||
filter do
|
||||
bool do
|
||||
must { term paper_type: options[:paper_type] } if options[:paper_type]
|
||||
must { match_all } unless options[:paper_type]
|
||||
must { term originator: options[:originator] } if options[:originator]
|
||||
# catchall when no filters set
|
||||
must { match_all } if options.keys.none? {|k| [:paper_type, :originator].include?(k) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue