Sha256: 4596ef3399d03a1e91825bdb67d30dac09c50518b2e2dadbb4ec7c11b2acdb37
Contents?: true
Size: 1.22 KB
Versions: 6
Compression:
Stored size: 1.22 KB
Contents
module Ddr::Batch class MonitorBatchStarted class << self def call(*args) event = ActiveSupport::Notifications::Event.new(*args) batch = Ddr::Batch::Batch.find(event.payload[:batch_id]) batch_started(batch) end private def batch_started(batch) clear_logs(batch) log_batch_start(batch) update_batch(batch) end def clear_logs(batch) # delete any previously existing filesystem log file for this batch Ddr::Batch::Log.clear_log(batch.id) # remove any existing attached log file from the Batch ActiveRecord object batch.logfile.clear end def log_batch_start(batch) logger = Ddr::Batch::Log.logger(batch.id) logger.info "Collection: #{batch.collection_title}" if batch.collection_title.present? logger.info "Batch id: #{batch.id}" logger.info "Batch name: #{batch.name}" if name logger.info "Batch size: #{batch.batch_objects.size}" logger.close end def update_batch(batch) batch.update!(start: DateTime.now, status: Ddr::Batch::Batch::STATUS_RUNNING, version: VERSION) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems