Skip to content

Instantly share code, notes, and snippets.

@jonstorer
Last active December 18, 2015 14:58
Show Gist options
  • Save jonstorer/5800783 to your computer and use it in GitHub Desktop.
Save jonstorer/5800783 to your computer and use it in GitHub Desktop.
Fetch member's email gift card code and challenge code for jen
require 'ruby-progressbar'
module PrizeMetaData
def self.run!
wins = PrizeWin.where(:drawing_id.in => Drawing.last_month.crowd.map(&:id))
progress = ProgressBar.create(:title => "#{Date::MONTHNAMES[1.month.ago.month]} Wins", :total => wins.count.to_i, :format => '%t |%b[%P%%]%i| %c/%C [%E]')
File.open("/home/deploy/tmp/prizing_#{Date::MONTHNAMES[1.month.ago.month].downcase}_email_codes_challenges.csv", 'a+') do |file|
file.puts "email, url, challenge"
wins.each do |win|
file.puts "#{win.member.email}, #{win.cashstar_fulfillment.url}, #{win.cashstar_fulfillment.challenge}"
progress.increment
end
end
end
end
@benson
Copy link

benson commented Jun 17, 2013

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment