aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application.rb10
-rw-r--r--app/controllers/general_controller.rb16
-rw-r--r--app/controllers/request_controller.rb4
-rw-r--r--app/controllers/track_controller.rb5
4 files changed, 19 insertions, 16 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index e36d21e22..6decd6591 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.44 2008-04-30 02:14:07 francis Exp $
+# $Id: application.rb,v 1.45 2008-05-15 17:40:43 francis Exp $
class ApplicationController < ActionController::Base
@@ -141,7 +141,7 @@ class ApplicationController < ActionController::Base
end
# Function for search
- def perform_search(query, sortby, collapse, per_page = 25, this_page = nil)
+ def perform_search(models, query, sortby, collapse, per_page = 25, this_page = nil)
@query = query
@sortby = sortby
@@ -157,11 +157,7 @@ class ApplicationController < ActionController::Base
else
@page = this_page
end
- xapian_object = InfoRequest.full_search(@query, order, ascending, collapse, @per_page, @page)
- @search_results = xapian_object.results
- @search_hits = xapian_object.matches_estimated
- @search_spelling = xapian_object.spelling_correction
- @highlight_words = xapian_object.words_to_highlight
+ return InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page)
end
# URL generating functions are needed by all controllers (for redirects),
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index afdbee82b..3c94940dd 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: general_controller.rb,v 1.22 2008-04-30 00:57:20 francis Exp $
+# $Id: general_controller.rb,v 1.23 2008-05-15 17:40:43 francis Exp $
class GeneralController < ApplicationController
@@ -35,7 +35,7 @@ class GeneralController < ApplicationController
# Get all successful requests for display on the right
query = 'variety:response (status:successful OR status:partially_successful)'
sortby = "newest"
- perform_search(query, sortby, 'request_collapse', 3)
+ @xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse', 3)
end
@@ -62,9 +62,17 @@ class GeneralController < ApplicationController
combined = combined[0..-2]
end
query = combined.join("/")
- perform_search(query, sortby, 'request_collapse')
- #render :controller => "help", :action => "about"
+ # Query each type separately for separate display
+ @xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse', 25)
+ @xapian_bodies = perform_search([PublicBody], query, sortby, nil, 5)
+ @xapian_users = perform_search([User], query, sortby, nil, 5)
+
+ @total_hits = @xapian_requests.matches_estimated + @xapian_bodies.matches_estimated + @xapian_users.matches_estimated
+
+ # Spelling and highight words are same for all three queries
+ @spelling_correction = @xapian_requests.spelling_correction
+ @highlight_words = @xapian_requests.words_to_highlight
end
# For debugging
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 719fd68e8..58ea944cb 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_controller.rb,v 1.83 2008-05-12 09:18:45 francis Exp $
+# $Id: request_controller.rb,v 1.84 2008-05-15 17:40:43 francis Exp $
class RequestController < ApplicationController
@@ -60,7 +60,7 @@ class RequestController < ApplicationController
else
raise "unknown request list view " + @view.to_s
end
- perform_search(query, sortby, 'request_collapse')
+ @xapian_object = perform_search([InfoRequestEvent], sortby, 'request_collapse')
end
# Page new form posts to
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index ebd9c7a30..7f0553a34 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: track_controller.rb,v 1.16 2008-05-12 17:55:18 francis Exp $
+# $Id: track_controller.rb,v 1.17 2008-05-15 17:40:43 francis Exp $
class TrackController < ApplicationController
@@ -130,8 +130,7 @@ class TrackController < ApplicationController
# Atom feed (like RSS) for the track
def atom_feed
@track_thing = TrackThing.find(params[:track_id].to_i)
-
- perform_search(@track_thing.track_query, @track_thing.params[:feed_sortby], nil, 25, 1)
+ @xapian_object = perform_search([InfoRequestEvent], @track_thing.track_query, @track_thing.params[:feed_sortby], nil, 25, 1)
respond_to :atom
end