aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/track_mailer.rb6
-rw-r--r--app/views/track_mailer/event_digest.rhtml8
-rw-r--r--spec/controllers/track_controller_spec.rb4
-rw-r--r--spec/fixtures/track_things.yml13
-rw-r--r--todo.txt6
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb4
6 files changed, 27 insertions, 14 deletions
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb
index 713bf3fca..b0dc0f27e 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.9 2008-05-15 17:40:43 francis Exp $
+# $Id: track_mailer.rb,v 1.10 2008-05-16 12:29:38 francis Exp $
class TrackMailer < ApplicationMailer
def event_digest(user, email_about_things)
@@ -57,7 +57,7 @@ class TrackMailer < ApplicationMailer
end
# If there were more alerts for this track, then store them
if alert_results.size > 0
- email_about_things.push([track_thing, alert_results])
+ email_about_things.push([track_thing, alert_results, xapian_object])
end
end
@@ -65,7 +65,7 @@ class TrackMailer < ApplicationMailer
if email_about_things.size > 0
# Debugging
STDERR.puts "sending email alert for user " + user.url_name
- for track_thing, alert_results in email_about_things
+ for track_thing, alert_results, xapian_object in email_about_things
STDERR.puts " tracking " + track_thing.track_query
for result in alert_results.reverse
STDERR.puts " result " + result[:model].class.to_s + " id " + result[:model].id.to_s
diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.rhtml
index 858f94516..f74be2854 100644
--- a/app/views/track_mailer/event_digest.rhtml
+++ b/app/views/track_mailer/event_digest.rhtml
@@ -1,12 +1,10 @@
-<% if @highlight_words.nil?
- @highlight_words = []
- end
-
+<%
# Construct the main text of the mail
main_text = ''
- for track_thing, alert_results in @email_about_things
+ for track_thing, alert_results, xapian_object in @email_about_things
main_text += track_thing.params[:title_in_email] + "\n"
main_text += ("=" * track_thing.params[:title_in_email].size) + "\n\n"
+ @highlight_words = xapian_object.words_to_highlight
for result in alert_results.reverse
if result[:model].class.to_s == "InfoRequestEvent"
event = result[:model]
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index bf3c952c7..39542cb63 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -24,12 +24,12 @@ describe TrackController, "when making a new track on a request" do
end
it "should make track and redirect if you are logged in " do
- TrackThing.count.should == 1
+ TrackThing.count.should == 2
session[:user_id] = users(:bob_smith_user).id
post :track_request, :url_title => info_requests(:fancy_dog_request).url_title,
:track_thing => { :track_medium => "email_daily" },
:submitted_track => 1
- TrackThing.count.should == 2
+ TrackThing.count.should == 3
response.should redirect_to(:controller => 'request', :action => 'show', :url_title => info_requests(:fancy_dog_request).url_title)
end
diff --git a/spec/fixtures/track_things.yml b/spec/fixtures/track_things.yml
index 863db3c50..1c4b323fd 100644
--- a/spec/fixtures/track_things.yml
+++ b/spec/fixtures/track_things.yml
@@ -1,4 +1,4 @@
-track_fancy_dog:
+track_fancy_dog_request:
id: "10"
track_query: request:why_do_you_have_such_a_fancy_dog
track_type: request_updates
@@ -9,3 +9,14 @@ track_fancy_dog:
public_body_id:
created_at: 2007-10-01 00:00:00
updated_at: 2007-01-01 00:00:00
+track_fancy_dog_search:
+ id: "11"
+ track_query: fancy dog
+ track_type: search_query
+ track_medium: email_daily
+ tracking_user_id: "2"
+ info_request_id:
+ tracked_user_id:
+ public_body_id:
+ created_at: 2007-10-01 00:00:00
+ updated_at: 2007-01-01 00:00:00
diff --git a/todo.txt b/todo.txt
index a3ebfaf8a..ccb21528b 100644
--- a/todo.txt
+++ b/todo.txt
@@ -37,14 +37,18 @@ Blog posts / Wikipedia articles about this request
Or just look at referrers as Julian says
Test: In email alerts, show request heading somewhere
+
Add test code for search track emails
Highlight words in them with *
and also highling in RSS
+ and highlight title
-Check test code coverage again
+Check test code coverage again - do we have all models
Reconsider described vs. newest for the tracks
+Fix up the privacy policy
+
Later
=====
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
index 976a5df19..cd4d14ba3 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.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: acts_as_xapian.rb,v 1.21 2008-05-15 11:20:47 francis Exp $
+# $Id: acts_as_xapian.rb,v 1.22 2008-05-16 12:29:39 francis Exp $
# Documentation
# =============
@@ -241,7 +241,7 @@ module ActsAsXapian
# date ranges or similar. Use this for cheap highlighting with
# TextHelper::highlight, and excerpt.
def words_to_highlight
- query_nopunc = self.query_string.gsub(/[^a-z0-9:\.\/]/i, " ")
+ query_nopunc = self.query_string.gsub(/[^a-z0-9:\.\/_]/i, " ")
query_nopunc = query_nopunc.gsub(/\s+/, " ")
words = query_nopunc.split(" ")
# Remove anything with a :, . or / in it