aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/stats.rake
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-11-15 11:39:12 +0000
committerMark Longair <mhl@pobox.com>2013-11-15 11:39:12 +0000
commit64618741c17760fcb59647d74d1ccaff56160b15 (patch)
treed84f1f035b136180f0bdacb22895fbb0f1abf2c1 /lib/tasks/stats.rake
parent96b3b5adbdafb25e5ab6ca94b89d6682a2e8f0e4 (diff)
parentcda26c36f309cdd8e8bbab9186f6cc0d4876e6c9 (diff)
Merge branch 'release/0.15' into wdtk
Conflicts: lib/tasks/stats.rake
Diffstat (limited to 'lib/tasks/stats.rake')
-rw-r--r--lib/tasks/stats.rake16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/tasks/stats.rake b/lib/tasks/stats.rake
index eb36204c6..38eb15996 100644
--- a/lib/tasks/stats.rake
+++ b/lib/tasks/stats.rake
@@ -1,8 +1,14 @@
namespace :stats do
- desc 'Produce transaction stats'
+ desc 'Produce monthly transaction stats for a period starting START_YEAR'
task :show => :environment do
- month_starts = (Date.new(2009, 1)..Date.new(2011, 8)).select { |d| d.day == 1 }
+ example = 'rake stats:show START_YEAR=2009 [START_MONTH=3 END_YEAR=2012 END_MONTH=10]'
+ check_for_env_vars(['START_YEAR'], example)
+ start_year = (ENV['START_YEAR']).to_i
+ start_month = (ENV['START_MONTH'] || 1).to_i
+ end_year = (ENV['END_YEAR'] || Time.now.year).to_i
+ end_month = (ENV['END_MONTH'] || Time.now.month).to_i
+ month_starts = (Date.new(start_year, start_month)..Date.new(end_year, end_month)).select { |d| d.day == 1 }
headers = ['Period',
'Requests sent',
'Annotations added',
@@ -103,7 +109,11 @@ namespace :stats do
overdue_count = 0
very_overdue_count = 0
InfoRequest.find_each(:batch_size => 200,
- :conditions => {:public_body_id => public_body.id}) do |ir|
+ :conditions => {
+ :public_body_id => public_body.id,
+ :awaiting_description => false,
+ :prominence => 'normal'
+ }) do |ir|
case ir.calculate_status
when 'waiting_response_very_overdue'
very_overdue_count += 1