diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-06-14 10:19:45 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-06-14 10:19:45 +0100 |
commit | c78e3b2aba67ad9844175e1e27016692759f498a (patch) | |
tree | b2555bab443ce173356c49dffeb7ebcc1224ea3d /lib/tasks | |
parent | 557a25aec4f41ebaba67349011052e04e1c68f9f (diff) | |
parent | f2b779ec4e095afeb1b1da2a92a335069c59dccd (diff) |
merge WTDK changes to master (preparation for closing WTDK branch and deploying WTDK website straight from master)
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/stats.rake | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/tasks/stats.rake b/lib/tasks/stats.rake new file mode 100644 index 000000000..e206ce951 --- /dev/null +++ b/lib/tasks/stats.rake @@ -0,0 +1,48 @@ +namespace :stats do + + desc 'Produce transaction stats' + task :show => :environment do + month_starts = (Date.new(2009, 1)..Date.new(2011, 5)).select { |d| d.day == 1 } + headers = ['Period', + 'Requests sent', + 'Annotations added', + 'Track this request email signups', + 'Comments on own requests', + 'Follow up messages sent'] + puts headers.join("\t") + month_starts.each do |month_start| + month_end = month_start.end_of_month + period = "#{month_start}-#{month_end}" + date_conditions = ['created_at >= ? + AND created_at < ?', + month_start, month_end+1] + request_count = InfoRequest.count(:conditions => date_conditions) + comment_count = Comment.count(:conditions => date_conditions) + track_conditions = ['track_type = ? + AND track_medium = ? + AND created_at >= ? + AND created_at < ?', + 'request_updates', 'email_daily', month_start, month_end+1] + email_request_track_count = TrackThing.count(:conditions => track_conditions) + comment_on_own_request_conditions = ['comments.user_id = info_requests.user_id + AND comments.created_at >= ? + AND comments.created_at < ?', + month_start, month_end+1] + comment_on_own_request_count = Comment.count(:conditions => comment_on_own_request_conditions, + :include => :info_request) + + followup_conditions = ['message_type = ? + AND created_at >= ? + AND created_at < ?', + 'followup', month_start, month_end+1] + follow_up_count = OutgoingMessage.count(:conditions => followup_conditions) + puts [period, + request_count, + comment_count, + email_request_track_count, + comment_on_own_request_count, + follow_up_count].join("\t") + end + end + +end
\ No newline at end of file |