Skip to content

Instantly share code, notes, and snippets.

@jonstorer
Last active December 18, 2015 02:58
Show Gist options
  • Save jonstorer/5714330 to your computer and use it in GitHub Desktop.
Save jonstorer/5714330 to your computer and use it in GitHub Desktop.
@members = {}
Brand.all.each do |brand|
if drawing = brand.drawings.crowd.last_month.first
wins = PrizeWin.where(:drawing_id => drawing.id)
progress = ProgressBar.create(:title => brand.slug, :total => wins.count.to_i, :format => '%t |%b[%P%%]%i| %c/%C [%E]')
wins.each do |win|
email = win.member.email
@members[email] ||= 0
@members[email] = @members[email].to_i + 1
progress.increment
end
end
end
File.open('/home/deploy/tmp/prizing.csv', 'w') do |file|
@members.each_pair do |email, count|
file.puts "#{email}, #{count}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment