diff options
author | louise <louise> | 2009-04-08 16:41:52 +0000 |
---|---|---|
committer | louise <louise> | 2009-04-08 16:41:52 +0000 |
commit | f92763ecad5aa728e6de5517afd74e16af96b6c8 (patch) | |
tree | 68c0c70e14898aa9dc0fd741c83399f1af1e87c2 | |
parent | 566427ddf41fd956122346fb813437e94a27b4c8 (diff) |
Reminders sent to users to update the status of their request now use InfoRequest.find_old_unclassified
-rw-r--r-- | app/models/request_mailer.rb | 7 | ||||
-rw-r--r-- | spec/models/request_mailer_spec.rb | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index b246abf76..b4fa82a42 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.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_mailer.rb,v 1.72 2009-04-08 07:31:07 francis Exp $ +# $Id: request_mailer.rb,v 1.73 2009-04-08 16:41:52 louise Exp $ class RequestMailer < ApplicationMailer @@ -253,7 +253,10 @@ class RequestMailer < ApplicationMailer end def self.alert_new_response_reminders_internal(days_since, type_code) #STDERR.puts "alert_new_response_reminders_internal days:" + days_since.to_s + " type: " + type_code - info_requests = InfoRequest.find(:all, :conditions => [ "awaiting_description = ? and info_requests.updated_at < ? and url_title != 'holding_pen'", true, Time.now() - days_since.days ], :include => [ :user ], :order => "info_requests.id" ) + info_requests = InfoRequest.find_old_unclassified(:order => 'info_requests.id', + :include => [:user], + :age_in_days => days_since) + for info_request in info_requests alert_event_id = info_request.get_last_response_event_id last_response_message = info_request.get_last_response diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 8fed44c4f..933d85870 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -153,8 +153,8 @@ describe RequestMailer, "when sending reminders to requesters to classify a resp RequestMailer.alert_new_response_reminders_internal(7, 'new_response_reminder_1') end - it 'should ask for all requests that are awaiting description and are not the holding pen and haven\'t been updated for the number of days given' do - expected_params = {:conditions => [ "awaiting_description = ? and info_requests.updated_at < ? and url_title != 'holding_pen'", + it 'should ask for all requests that are awaiting description and whose latest response is older than the number of days given and that are not the holding pen' do + expected_params = {:conditions => [ "awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen'", true, Time.now() - 7.days ], :include => [ :user ], :order => "info_requests.id"} |