aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorlouise <louise>2009-04-08 10:45:33 +0000
committerlouise <louise>2009-04-08 10:45:33 +0000
commit7431967ab6cc58d8ea7670ac04b6f35e817a70d9 (patch)
tree4002884ab054b538c5c7d62cea1ddf352e9d9534 /app/models/info_request.rb
parentf5c5200d1305ce8954ab64f0619177cff22dcb3c (diff)
Moving logic for determining old and unclassified requests to the model in preparation for allowing anyone to edit them
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 0dec0528a..7ea355a18 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.183 2009-04-08 07:31:07 francis Exp $
+# $Id: info_request.rb,v 1.184 2009-04-08 10:45:34 louise Exp $
require 'digest/sha1'
require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian')
@@ -73,6 +73,8 @@ class InfoRequest < ActiveRecord::Base
'foi', # Freedom of Information Act
'eir', # Environmental Information Regulations
]
+
+ OLD_AGE_IN_DAYS = 10.days
def after_initialize
if self.described_state.nil?
@@ -673,6 +675,24 @@ public
def InfoRequest.last_event_time_clause
'(select created_at from info_request_events where info_request_events.info_request_id = info_requests.id order by created_at desc limit 1)'
end
+
+ def InfoRequest.find_old_unclassified(limit=nil)
+ params = {:select => "*, #{last_event_time_clause} as last_event_time",
+ :conditions => ["awaiting_description = ? and #{last_event_time_clause} < ? and prominence != 'backpage'",
+ true, Time.now() - OLD_AGE_IN_DAYS],
+ :order => "last_event_time"}
+ params[:limit] = limit if limit
+ find(:all, params)
+ end
+
+ def is_old_unclassified?
+ return false if !awaiting_description
+ return false if prominence == 'backpage'
+ last_event = get_last_event
+ return false unless last_event
+ return false if last_event.created_at >= Time.now - OLD_AGE_IN_DAYS
+ return true
+ end
# List of incoming messages to followup, by unique email
def who_can_followup_to