Sha256: 815452a9177cd66f5d9f6b9fffa37b932c1d55b92e772c4681fd419506993e66

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

# Transfer schedule_items from previous year

def transfer_schedule_items
  current = Event.current
  past = Event.find_by_slug('2012')

  Event.current.dates.each_with_index do |day, i|
    past_date = past.dates[i]
    offset = (day - past_date).days

    past.schedule_items.select{|s| s.start_time.to_date == past_date}.each do |past_schedule_item|
      new_attributes = past_schedule_item.attributes
      new_attributes.delete("created_at")
      new_attributes.delete("updated_at")
      new_attributes.delete("id")
      new_attributes.delete("room_id")
      new_attributes["start_time"] += offset
      new_schedule_item = current.schedule_items.new(new_attributes)
      puts "#{new_schedule_item.start_time}: #{new_schedule_item.title}"
      new_schedule_item.save
    end
  end
end

transfer_schedule_items()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
open_conference_ware-1.0.0.pre4 util/transfer_schedule_items.rb
open_conference_ware-1.0.0.pre3 util/transfer_schedule_items.rb