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