Skip to content

Instantly share code, notes, and snippets.

@zaeem
Last active August 29, 2015 14:03
Show Gist options
  • Save zaeem/a1600811aedd50e22d99 to your computer and use it in GitHub Desktop.
Save zaeem/a1600811aedd50e22d99 to your computer and use it in GitHub Desktop.
# File name assumption is 70.csv and 35.csv and this will only run for 1 event and 2 races in that one event.
# This specific to the event id = 41211
#Dev
# Event_id = 8
# Race1 = 19
# Race2 = 20
#Production
Event_id = 41211
Race1 = 84651
Race2 = 84601
ExpDate = DateTime.parse("2014-07-11 12:00:00")
File.open('70.csv').each do |line|
begin
@race = Race.find(Race1)
code = line
expiration = ExpDate
left_over_uses = 1
default_uses = 0
event_id = Event_id
value = 70
@coupon = @race.coupons.create!(
code: code,
expiration: expiration,
left_over_uses: left_over_uses,
default_uses: default_uses,
event_id: event_id,
value: value
)
@race = Race.find(Race2)
@race.coupons << @coupon
rescue Exception => ex
puts "------------"
puts ex.message
end
end
File.open('35.csv').each do |line|
begin
@race = Race.find(Race1)
code = line
expiration = ExpDate
left_over_uses = 1
default_uses = 0
event_id = Event_id
value = 35
@coupon = @race.coupons.create!(
code: code,
expiration: expiration,
left_over_uses: left_over_uses,
default_uses: default_uses,
event_id: event_id,
value: value
)
@race = Race.find(Race2)
@race.coupons << @coupon
rescue Exception => ex
puts "------------"
puts ex.message
end
end
@zaeem
Copy link
Author

zaeem commented Jul 2, 2014

File name assumption is 70.csv and 35.csv and this will only run for 1 event and 2 races in that one event.

This specific to the event id = 41211

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