From c8fc7884e1e13e7a46ea720fe7fd4d47d095a67f Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 30 Oct 2014 12:47:58 +0000 Subject: 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 --- app/controllers/request_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'app/controllers/request_controller.rb') 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 -- cgit v1.2.3 From a9853bf1a41623df1b84656ce8dac6f01231f2cd Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 30 Oct 2014 14:58:40 +0000 Subject: RequestController#search_typaahead limit results Use the per_page parameter to limit the results returned --- app/controllers/request_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 9f17532b8..346aaf384 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -908,8 +908,10 @@ class RequestController < ApplicationController @query << "requested_from:#{ params[:requested_from] } " end + @per_page = (params.fetch(:per_page) { 25 }).to_i + @query << params[:q] - @xapian_requests = perform_search_typeahead(@query, InfoRequestEvent) + @xapian_requests = perform_search_typeahead(@query, InfoRequestEvent, @per_page) render :partial => "request/search_ahead" end -- cgit v1.2.3