aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorfrancis <francis>2008-04-14 14:46:47 +0000
committerfrancis <francis>2008-04-14 14:46:47 +0000
commitc62db4918a9a4497fc85628bd07110e55ad8fac5 (patch)
tree176625fb26948485af522d2fa88c954c9dda3296 /app/models
parent9f13a2297f2dd3c5e9a68025d8d07dd5571f78cd (diff)
Centralise call to multi_solr_search
Diffstat (limited to 'app/models')
-rw-r--r--app/models/info_request.rb18
-rw-r--r--app/models/track_mailer.rb15
2 files changed, 19 insertions, 14 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index cf4d6c206..775138b84 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -22,7 +22,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request.rb,v 1.84 2008-04-14 10:05:21 francis Exp $
+# $Id: info_request.rb,v 1.85 2008-04-14 14:46:48 francis Exp $
require 'digest/sha1'
@@ -111,6 +111,22 @@ class InfoRequest < ActiveRecord::Base
true
end
+ # Central function to do all searches
+ def InfoRequest.full_search(query, order, per_page, page, html_highlight)
+ offset = (page - 1) * per_page
+ return InfoRequestEvent.multi_solr_search(query, :models => [ PublicBody, User ],
+ :limit => per_page, :offset => offset,
+ :highlight => {
+ :prefix => html_highlight ? '<span class="highlight">' : "*",
+ :suffix => html_highlight ? '</span>' : "*",
+ :fragsize => 250,
+ :fields => ["solr_text_main", "title", # InfoRequestEvent
+ "name", "short_name", # PublicBody
+ "name" # User
+ ]}, :order => order
+ )
+ end
+
public
# When name is changed, also change the url name
def title=(title)
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb
index 119654009..c5d2ef35f 100644
--- a/app/models/track_mailer.rb
+++ b/app/models/track_mailer.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: track_mailer.rb,v 1.5 2008-04-09 01:32:53 francis Exp $
+# $Id: track_mailer.rb,v 1.6 2008-04-14 14:46:48 francis Exp $
class TrackMailer < ApplicationMailer
def event_digest(user, email_about_things)
@@ -41,18 +41,7 @@ class TrackMailer < ApplicationMailer
end
# Query for things in this track
- # XXX remove duplication with controllers/application.rb
- #perform_search(track_thing.track_query, 'newest', 100, 1, false)
- solr_object = InfoRequestEvent.multi_solr_search(track_thing.track_query, :models => [ PublicBody, User ],
- :limit => 100, :offset => 0,
- :highlight => {
- :prefix => "*", :suffix => "*",
- :fragsize => 250,
- :fields => ["solr_text_main", "title", # InfoRequestEvent
- "name", "short_name", # PublicBody
- "name" # User
- ]}, :order => 'created_at desc'
- )
+ solr_object = InfoRequest.full_search(track_thing.track_query, 'created_at desc', 100, 1, false)
# Go through looking for unalerted things
alert_results = []