aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_general_controller.rb4
-rw-r--r--app/controllers/admin_request_controller.rb12
-rw-r--r--app/models/info_request.rb22
3 files changed, 25 insertions, 13 deletions
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index 3d2bf74df..cbb381e21 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.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: admin_general_controller.rb,v 1.3 2009-03-10 12:04:55 tony Exp $
+# $Id: admin_general_controller.rb,v 1.4 2009-04-08 10:45:33 louise Exp $
class AdminGeneralController < AdminController
def index
@@ -19,7 +19,7 @@ class AdminGeneralController < AdminController
@requires_admin_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'requires_admin'"], :order => "last_event_time")
@error_message_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'error_message'"], :order => "last_event_time")
@blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"], :order => "updated_at")
- @ten_days_old_unclassified = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => [ "awaiting_description = ? and " + InfoRequest.last_event_time_clause + " < ? and prominence != 'backpage'", true, Time.now() - 10.days ], :order => "last_event_time", :limit => 50)
+ @ten_days_old_unclassified = InfoRequest.find_old_unclassified(limit=50)
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
end
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 18a577443..15faacac2 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.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: admin_request_controller.rb,v 1.32 2009-04-08 04:51:37 francis Exp $
+# $Id: admin_request_controller.rb,v 1.33 2009-04-08 10:45:33 louise Exp $
class AdminRequestController < AdminController
def index
@@ -19,15 +19,7 @@ class AdminRequestController < AdminController
end
def list_old_unclassified
- @info_requests = InfoRequest.find(
- :all,
- :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time',
- :conditions => [
- "awaiting_description = ? and " + InfoRequest.last_event_time_clause + " < ? and prominence != 'backpage'",
- true, Time.now() - 10.days
- ],
- :order => "last_event_time"
- )
+ @info_requests = InfoRequest.find_old_unclassified
end
def show
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