diff options
Diffstat (limited to 'app/workers/bulk_imports/finish_batched_pipeline_worker.rb')
-rw-r--r-- | app/workers/bulk_imports/finish_batched_pipeline_worker.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/workers/bulk_imports/finish_batched_pipeline_worker.rb b/app/workers/bulk_imports/finish_batched_pipeline_worker.rb index b953f8ab786..973889e1411 100644 --- a/app/workers/bulk_imports/finish_batched_pipeline_worker.rb +++ b/app/workers/bulk_imports/finish_batched_pipeline_worker.rb @@ -22,9 +22,11 @@ module BulkImports return re_enqueue if import_in_progress? if tracker.stale? + logger.error(log_attributes(message: 'Tracker stale. Failing batches and tracker')) tracker.batches.map(&:fail_op!) tracker.fail_op! else + logger.info(log_attributes(message: 'Tracker finished')) tracker.finish! end end @@ -40,5 +42,20 @@ module BulkImports def import_in_progress? tracker.batches.any? { |b| b.started? || b.created? } end + + def logger + @logger ||= Logger.build + end + + def log_attributes(extra = {}) + structured_payload( + { + tracker_id: tracker.id, + bulk_import_id: tracker.entity.id, + bulk_import_entity_id: tracker.entity.bulk_import_id, + pipeline_class: tracker.pipeline_name + }.merge(extra) + ) + end end end |