Adding rake statistics:genders to list all genders with profile count

This commit is contained in:
Thomas R. Koll 2010-12-30 14:18:12 +01:00
parent 61d0f0ea65
commit be270c4696

View file

@ -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