Sha256: 42504a97ad0bc5cf109fa24a8af3b853d85e4890525ef658c491063a7ea72b63
Contents?: true
Size: 1.14 KB
Versions: 8
Compression:
Stored size: 1.14 KB
Contents
module CanvasSync module Jobs class BeginSyncChainJob < CanvasSync::Job def perform(chain_definition, globals = {}) if !globals[:updated_after].present? || globals[:updated_after] == true last_batch = SyncBatch.where(status: 'completed').last globals[:updated_after] = last_batch&.started_at&.iso8601 end sync_batch = SyncBatch.create!( started_at: DateTime.now, status: 'pending', ) JobBatches::Batch.new.tap do |b| b.description = "CanvasSync Root Batch" b.on(:complete, "#{self.class.to_s}.batch_completed", sync_batch_id: sync_batch.id) b.on(:success, "#{self.class.to_s}.batch_completed", sync_batch_id: sync_batch.id) b.context = globals b.jobs do JobBatches::SerialBatchJob.perform_now(chain_definition) end end end def self.batch_completed(status, options) sbatch = SyncBatch.find(options['sync_batch_id']) sbatch.update!( status: status.success? ? 'completed' : 'failed', completed_at: DateTime.now, ) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems