aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorfrancis <francis>2008-11-10 11:18:39 +0000
committerfrancis <francis>2008-11-10 11:18:39 +0000
commite39e474d4d79ac4286b61825dc484e510f403fa8 (patch)
tree8ed399faed2da112242089ac98df96413a11d77f /app/models/info_request.rb
parent007ecedb11ba67a385979b52ffff1804c553a0f1 (diff)
Calculate state of calrification / internal review request follow ups, so they appear in
that kind of search result.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index ff00235ed..0b038bc25 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -23,7 +23,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.153 2008-11-07 00:01:50 francis Exp $
+# $Id: info_request.rb,v 1.154 2008-11-10 11:18:39 francis Exp $
require 'digest/sha1'
require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian')
@@ -372,7 +372,7 @@ public
def calculate_event_states
curr_state = nil
for event in self.info_request_events.reverse
- if not event.described_state.nil? and curr_state.nil?
+ if !event.described_state.nil? && curr_state.nil?
curr_state = event.described_state
#STDERR.puts "curr_state " + curr_state
end
@@ -389,10 +389,20 @@ public
end
curr_state = nil
elsif !curr_state.nil? && event.event_type == 'followup_sent' && !event.described_state.nil? && (event.described_state == 'waiting_response' || event.described_state == 'internal_review')
- # followups can set the status to waiting response / internal
- # review, which we don't want to propogate to the response
- # itself, as that might already be set to waiting_clarification
- # / a success status, which we want to know about.
+ # Followups can set the status to waiting response / internal
+ # review.
+
+ # We want to store that in calculated_state state so it gets
+ # indexed.
+ if event.calculated_state != event.described_state
+ event.calculated_state = event.described_state
+ event.last_described_at = Time.now()
+ event.save!
+ end
+
+ # And we don't want to propogate it to the response itself,
+ # as that might already be set to waiting_clarification / a
+ # success status, which we want to know about.
curr_state = nil
end
end