aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/general_controller.rb4
-rw-r--r--app/models/info_request.rb11
-rw-r--r--app/models/info_request_event.rb3
-rw-r--r--db/migrate/048_add_calculated_state_at.rb10
-rw-r--r--db/schema.rb11
-rw-r--r--todo.txt1
6 files changed, 29 insertions, 11 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 4eb671af6..16f34f1b8 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: general_controller.rb,v 1.13 2008-03-31 19:15:30 francis Exp $
+# $Id: general_controller.rb,v 1.14 2008-03-31 23:19:16 francis Exp $
class GeneralController < ApplicationController
@@ -61,6 +61,8 @@ class GeneralController < ApplicationController
order = nil
elsif @sortby == 'newest'
order = 'created_at desc'
+ elsif @sortby == 'described'
+ order = 'last_described_at desc' # use this for RSS
else
raise "Unknown sort order " + @sortby
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 791bbf753..1bc6004aa 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.77 2008-03-31 19:15:38 francis Exp $
+# $Id: info_request.rb,v 1.78 2008-03-31 23:19:16 francis Exp $
require 'digest/sha1'
@@ -244,10 +244,13 @@ public
curr_state = event.described_state
end
- if not curr_state.nil? and event.event_type == 'response'
- event.calculated_state = curr_state
+ if !curr_state.nil? && event.event_type == 'response'
+ if event.calculated_state != curr_state
+ event.calculated_state = curr_state
+ event.last_described_at = Time.now()
+ event.save!
+ end
curr_state = nil
- event.save!
end
end
end
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 5b176c1e5..d1798511b 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.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_event.rb,v 1.29 2008-03-31 22:41:34 francis Exp $
+# $Id: info_request_event.rb,v 1.30 2008-03-31 23:19:16 francis Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
@@ -56,6 +56,7 @@ class InfoRequestEvent < ActiveRecord::Base
{ :requested_by => :string },
{ :requested_from => :string },
{ :created_at => :date },
+ { :last_described_at => :date },
{ :variety => :string }
], :if => "$do_solr_index"
def status # for name in Solr queries
diff --git a/db/migrate/048_add_calculated_state_at.rb b/db/migrate/048_add_calculated_state_at.rb
new file mode 100644
index 000000000..63f7e996d
--- /dev/null
+++ b/db/migrate/048_add_calculated_state_at.rb
@@ -0,0 +1,10 @@
+class AddCalculatedStateAt < ActiveRecord::Migration
+ def self.up
+ # This is for use in RSS feeds
+ add_column :info_request_events, :last_described_at, :datetime
+ end
+
+ def self.down
+ remove_column :info_request_events, :last_described_at
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6f4c975ae..7083fbfd6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 47) do
+ActiveRecord::Schema.define(:version => 48) do
create_table "incoming_messages", :force => true do |t|
t.integer "info_request_id", :null => false
@@ -19,12 +19,13 @@ ActiveRecord::Schema.define(:version => 47) do
end
create_table "info_request_events", :force => true do |t|
- t.integer "info_request_id", :null => false
- t.text "event_type", :null => false
- t.text "params_yaml", :null => false
- t.datetime "created_at", :null => false
+ t.integer "info_request_id", :null => false
+ t.text "event_type", :null => false
+ t.text "params_yaml", :null => false
+ t.datetime "created_at", :null => false
t.string "described_state"
t.string "calculated_state"
+ t.datetime "last_described_at"
end
create_table "info_requests", :force => true do |t|
diff --git a/todo.txt b/todo.txt
index a1525b820..aba89063f 100644
--- a/todo.txt
+++ b/todo.txt
@@ -157,6 +157,7 @@ Quoting fixing TODO:
http://www.whatdotheyknow.com/request/55/response/96
http://www.whatdotheyknow.com/request/71/response/108
http://www.whatdotheyknow.com/request/police_powers_to_inform_car_insu
+ http://www.whatdotheyknow.com/request/30/response/166
Char encoding:
http://www.whatdotheyknow.com/request/107/response/144