Sha256: 69b5786694ff0ca642575a1fe6ec59ea8b5497e1523f4234115c68656c781866
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 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.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.failures.positive? ? 'failed' : 'completed', completed_at: DateTime.now, ) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems