From 61d0f0ea6562c5df492c00b63efd115ad0152686 Mon Sep 17 00:00:00 2001 From: "Thomas R. Koll" Date: Thu, 30 Dec 2010 13:35:27 +0100 Subject: [PATCH 1/2] Feature #717: Adding rake tasks to print statistics on users and content Adds following rake tasks: rake statistics:users rake statistics:content --- lib/tasks/statistics.rake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/tasks/statistics.rake diff --git a/lib/tasks/statistics.rake b/lib/tasks/statistics.rake new file mode 100644 index 000000000..f8dfaffe5 --- /dev/null +++ b/lib/tasks/statistics.rake @@ -0,0 +1,21 @@ +namespace :statistics do + desc 'on users: total, active' + task :users => :environment do + puts "Users: %i and %i incomplete" % [User.where(:getting_started => false).count, + User.where(:getting_started => true, :sign_in_count.gt => 0).count] + puts "Invitations sent: %i" % Invitation.count + puts "Contacts: %i and %i pending" % [p = Contact.where(:pending => false).count, Contact.count - p] + puts "Aspects: %i" % Aspect.count + puts "Users signed in in last 24h: %i" % User.where(:current_sign_in_at.gt => Time.now - 1.day).count + puts "Users signed in in last 7d: %i" % User.where(:current_sign_in_at.gt => Time.now - 7.days).count + end + + desc 'on content: posts, photos, status messages, comments' + task :content => :environment do + puts "Services: %i Facebook, %i Twitter" % [Services::Facebook.count, Services::Twitter.count] + puts "Posts: %i and %i are public" % [Post.count, Post.where(:public => true).count] + puts "Status messages: %i" % [StatusMessage.count, StatusMessage.where(:public => true).count] + puts "Comments: %i" % Comment.count + puts "Photos: %i" % Photo.count + end +end From be270c46960f8a2e7dd4914cd9dbb0785957cb10 Mon Sep 17 00:00:00 2001 From: "Thomas R. Koll" Date: Thu, 30 Dec 2010 14:18:12 +0100 Subject: [PATCH 2/2] Adding rake statistics:genders to list all genders with profile count --- lib/tasks/statistics.rake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/tasks/statistics.rake b/lib/tasks/statistics.rake index f8dfaffe5..11beca982 100644 --- a/lib/tasks/statistics.rake +++ b/lib/tasks/statistics.rake @@ -18,4 +18,11 @@ namespace :statistics do puts "Comments: %i" % Comment.count puts "Photos: %i" % Photo.count end + task :genders => :environment do + genders = Person.collection.group(['profile.gender'], {}, {:count => 0}, 'function(o,p) { p.count++; }', true ) + genders.sort!{|a,b| a['profile.gender'].to_s <=> b['profile.gender'].to_s} + genders.each do |gender| + puts "%s: %i" % [gender['profile.gender']||'none given', gender['count']] + end + end end