Skip to content

Instantly share code, notes, and snippets.

@thefron
Created January 17, 2014 08:19
Show Gist options
  • Save thefron/8470046 to your computer and use it in GitHub Desktop.
Save thefron/8470046 to your computer and use it in GitHub Desktop.
birthyears_users = {}
User.unscoped.registered.select([:id, :birthday]).find_each do |user|
if user.birthday
birthyears_users[user.birthday.year] ||= []
birthyears_users[user.birthday.year] << user.id
else
birthyears_users[0] ||= []
birthyears_users[0] << user.id
end
end; nil
birthyears_users.sort.each do |year, user_ids|
puts "#{year}\t#{user_ids.count}"
end; nil
birthyears_users = {}
User.unscoped.where(service_zone_id: 'taiwan').registered.select([:id, :birthday]).find_each do |user|
if user.birthday
birthyears_users[user.birthday.year] ||= []
birthyears_users[user.birthday.year] << user.id
else
birthyears_users[0] ||= []
birthyears_users[0] << user.id
end
end; nil
birthyears_users.sort.each do |year, user_ids|
puts "#{year}\t#{user_ids.count}"
end; nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment