diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-10-30 12:47:58 +0000 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-11-11 16:02:18 +0000 |
commit | c8fc7884e1e13e7a46ea720fe7fd4d47d095a67f (patch) | |
tree | 723c2cc79963fbfc53eaa476cde69dbff95bce43 /app/controllers/request_controller.rb | |
parent | 89742de35899c1ca08693fc7dd56bf233ab44fd7 (diff) |
RequestController#search_typeahead filter by body
Action now supports the `request_from` param as per the Xapian filtering
system to filter search typeaheads by public body
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r-- | app/controllers/request_controller.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 9e2c291dc..9f17532b8 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -900,10 +900,16 @@ class RequestController < ApplicationController # Type ahead search def search_typeahead - # Since acts_as_xapian doesn't support the Partial match flag, we work around it - # by making the last work a wildcard, which is quite the same - query = params[:q] - @xapian_requests = perform_search_typeahead(query, InfoRequestEvent) + # Since acts_as_xapian doesn't support the Partial match flag, we work + # around it by making the last word a wildcard, which is quite the same + @query = '' + + if params.key?(:requested_from) + @query << "requested_from:#{ params[:requested_from] } " + end + + @query << params[:q] + @xapian_requests = perform_search_typeahead(@query, InfoRequestEvent) render :partial => "request/search_ahead" end |