aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/info_request.rb6
-rw-r--r--app/models/outgoing_message.rb4
-rw-r--r--db/migrate/023_outgoing_message_last_sent_at.rb9
-rw-r--r--db/schema.rb4
-rw-r--r--spec/fixtures/outgoing_messages.yml2
-rw-r--r--todo.txt2
6 files changed, 18 insertions, 9 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 57a1a422f..8447dcbc4 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -17,7 +17,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.21 2008-01-02 18:16:39 francis Exp $
+# $Id: info_request.rb,v 1.22 2008-01-02 20:13:01 francis Exp $
require 'digest/sha1'
@@ -92,7 +92,9 @@ class InfoRequest < ActiveRecord::Base
overdue = false
# XXX if a second outgoing message is really a new request, then this
# is no good
- earliest_sent = self.outgoing_messages.map { |om| om.sent_at }.min
+ # We use the last_sent_at date for each outgoing message, as fair
+ # enough if the first email bounced or something and it got recent.
+ earliest_sent = self.outgoing_messages.map { |om| om.last_sent_at }.min
time_left = Time.now - earliest_sent
# XXX use working days
if time_left > 20.days
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 823557e6b..7cf92a4db 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -20,7 +20,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: outgoing_message.rb,v 1.16 2008-01-02 16:04:53 francis Exp $
+# $Id: outgoing_message.rb,v 1.17 2008-01-02 20:13:01 francis Exp $
class OutgoingMessage < ActiveRecord::Base
belongs_to :info_request
@@ -55,7 +55,7 @@ class OutgoingMessage < ActiveRecord::Base
if self.message_type == 'initial_request'
if self.status == 'ready'
RequestMailer.deliver_initial_request(self.info_request, self)
- self.sent_at = Time.now
+ self.last_sent_at = Time.now
self.status = 'sent'
self.save!
self.info_request.log_event(log_event_type, { :email => self.info_request.recipient_email, :outgoing_message_id => self.id })
diff --git a/db/migrate/023_outgoing_message_last_sent_at.rb b/db/migrate/023_outgoing_message_last_sent_at.rb
new file mode 100644
index 000000000..24cb55257
--- /dev/null
+++ b/db/migrate/023_outgoing_message_last_sent_at.rb
@@ -0,0 +1,9 @@
+class OutgoingMessageLastSentAt < ActiveRecord::Migration
+ def self.up
+ rename_column(:outgoing_messages, :sent_at, :last_sent_at)
+ end
+
+ def self.down
+ rename_column(:outgoing_messages, :last_sent_at, :sent_at)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f2032fdc5..38257f742 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2,7 +2,7 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
-ActiveRecord::Schema.define(:version => 22) do
+ActiveRecord::Schema.define(:version => 23) do
create_table "incoming_messages", :force => true do |t|
t.column "info_request_id", :integer
@@ -35,7 +35,7 @@ ActiveRecord::Schema.define(:version => 22) do
t.column "message_type", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
- t.column "sent_at", :datetime
+ t.column "last_sent_at", :datetime
end
create_table "post_redirects", :force => true do |t|
diff --git a/spec/fixtures/outgoing_messages.yml b/spec/fixtures/outgoing_messages.yml
index db7e24d5f..2f72392bd 100644
--- a/spec/fixtures/outgoing_messages.yml
+++ b/spec/fixtures/outgoing_messages.yml
@@ -11,6 +11,6 @@ useless_outgoing_message:
Thanks!\r\n\
\r\n\
Francis\r\n"
- sent_at: 2007-10-25 10:41:12.686264
+ last_sent_at: 2007-10-25 10:41:12.686264
created_at: 2007-10-12 01:56:58.586598
diff --git a/todo.txt b/todo.txt
index 41be1124c..cfbeee84c 100644
--- a/todo.txt
+++ b/todo.txt
@@ -19,8 +19,6 @@ BAILII - relationship with law courts, robots.txt ?
Next
====
-Rename outgoing_message.sent_at as last_sent_at
-
Make response messages go to a mailbox as backup
Make it so if the pipe fails, exim tries again rather than sending an error to the public body.
Or so errors go to an admin somehow, at the very least.