diff options
Diffstat (limited to 'app/workers/bulk_import_worker.rb')
-rw-r--r-- | app/workers/bulk_import_worker.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/workers/bulk_import_worker.rb b/app/workers/bulk_import_worker.rb index 8ad31c68374..25a86ead76e 100644 --- a/app/workers/bulk_import_worker.rb +++ b/app/workers/bulk_import_worker.rb @@ -15,7 +15,8 @@ class BulkImportWorker # rubocop:disable Scalability/IdempotentWorker @bulk_import = BulkImport.find_by_id(bulk_import_id) return unless @bulk_import - return if @bulk_import.finished? + return if @bulk_import.finished? || @bulk_import.failed? + return @bulk_import.fail_op! if all_entities_failed? return @bulk_import.finish! if all_entities_processed? && @bulk_import.started? return re_enqueue if max_batch_size_exceeded? # Do not start more jobs if max allowed are already running @@ -55,6 +56,10 @@ class BulkImportWorker # rubocop:disable Scalability/IdempotentWorker entities.all? { |entity| entity.finished? || entity.failed? } end + def all_entities_failed? + entities.all? { |entity| entity.failed? } + end + def max_batch_size_exceeded? started_entities.count >= DEFAULT_BATCH_SIZE end |