Sha256: d025e3fa8135e2ab0890f51e8a6abf94939b203e0cbc988fdaf9affd40e9e6d6

Contents?: true

Size: 1.1 KB

Versions: 18

Compression:

Stored size: 1.1 KB

Contents

class ShowCreator < Struct.new(:datetimes, :show_params, :chart_params, :event, :organization, :publish)

  #
  # If datetime.length < 3, the shows will create right away. Otherwise, they'll be queued
  #
  def self.enqueue(datetimes, show_params, chart_params, event, organization, publish = false)
    datetimes ||= []
    creator = ShowCreator.new(datetimes, show_params, chart_params, event, organization, publish)
    if datetimes.length < 3
      creator.perform
    else
      Delayed::Job.enqueue(creator)
    end
  end

  def perform
    ActiveRecord::Base.transaction do
      datetimes.each do |f|     
        @show = self.event.next_show 
        
        #clear the sections and replace them with whatever they entered
        @show.chart.sections = []
        @show.chart.update_attributes_from_params(chart_params)
        @show.update_attributes(show_params)
        @show.organization = organization
        @show.chart_id = @show.chart.id

        @show.datetime = ActiveSupport::TimeZone.create(self.event.time_zone).parse(DateTime.parse(f).to_s)
        @show.go!(publish)      
      end
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.19 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.18 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.17 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.16 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.15 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.12 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.11 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.10 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.9 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.8 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.7 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.6 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.5 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.4 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.3 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.2 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre.1 app/models/job/show_creator.rb
artfully_ose-1.2.0.pre app/models/job/show_creator.rb