Adding rake statistics:genders to list all genders with profile count
This commit is contained in:
parent
61d0f0ea65
commit
be270c4696
1 changed files with 7 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue