aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb8
-rw-r--r--app/controllers/user_controller.rb6
-rw-r--r--app/mailers/track_mailer.rb6
-rw-r--r--app/models/info_request.rb15
4 files changed, 17 insertions, 18 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index df522519d..4f3624ab7 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -378,7 +378,13 @@ class ApplicationController < ActionController::Base
else
@page = this_page
end
- result = InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page)
+ result = ActsAsXapian::Search.new(models, @query,
+ :offset => (@page - 1) * @per_page,
+ :limit => @per_page,
+ :sort_by_prefix => order,
+ :sort_by_ascending => ascending,
+ :collapse_by_prefix => collapse
+ )
result.results # Touch the results to load them, otherwise accessing them from the view
# might fail later if the database has subsequently been reopened.
return result
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 658daeeff..ed05b750b 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -119,7 +119,11 @@ class UserController < ApplicationController
@track_things = TrackThing.find(:all, :conditions => ["tracking_user_id = ? and track_medium = ?", @display_user.id, 'email_daily'], :order => 'created_at desc')
for track_thing in @track_things
# XXX factor out of track_mailer.rb
- xapian_object = InfoRequest.full_search([InfoRequestEvent], track_thing.track_query, 'described_at', true, nil, 20, 1)
+ xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query,
+ :sort_by_prefix => 'described_at',
+ :sort_by_ascending => true,
+ :collapse_by_prefix => nil,
+ :limit => 20)
feed_results += xapian_object.results.map {|x| x[:model]}
end
end
diff --git a/app/mailers/track_mailer.rb b/app/mailers/track_mailer.rb
index ea5489726..bd9ce658d 100644
--- a/app/mailers/track_mailer.rb
+++ b/app/mailers/track_mailer.rb
@@ -67,7 +67,11 @@ class TrackMailer < ApplicationMailer
# Query for things in this track. We use described_at for the
# ordering, so we catch anything new (before described), or
# anything whose new status has been described.
- xapian_object = InfoRequest.full_search([InfoRequestEvent], track_thing.track_query, 'described_at', true, nil, 100, 1)
+ xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query,
+ :sort_by_prefix => 'described_at',
+ :sort_by_ascending => true,
+ :collapse_by_prefix => nil,
+ :limit => 100)
# Go through looking for unalerted things
alert_results = []
for result in xapian_object.results
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 156399b99..4db4dadb0 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -189,21 +189,6 @@ class InfoRequest < ActiveRecord::Base
self.comments.find(:all, :conditions => 'visible')
end
- # Central function to do all searches
- # (Not really the right place to put it, but everything can get it here, and it
- # does *mainly* find info requests, via their events, so hey)
- def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page)
- offset = (page - 1) * per_page
-
- return ::ActsAsXapian::Search.new(
- models, query,
- :offset => offset, :limit => per_page,
- :sort_by_prefix => order,
- :sort_by_ascending => ascending,
- :collapse_by_prefix => collapse
- )
- end
-
# If the URL name has changed, then all request: queries will break unless
# we update index for every event. Also reindex if prominence changes.
after_update :reindex_some_request_events