2022-11-19 06:03:59 +01:00
|
|
|
class BatchOperationProcessOneJob < ApplicationJob
|
2022-11-25 15:43:00 +01:00
|
|
|
retry_on StandardError, attempts: 1
|
|
|
|
|
2022-11-18 16:59:46 +01:00
|
|
|
def perform(batch_operation, dossier)
|
2022-11-25 15:43:00 +01:00
|
|
|
dossier = batch_operation.dossiers_safe_scope.find(dossier.id)
|
2022-11-18 16:59:46 +01:00
|
|
|
begin
|
|
|
|
batch_operation.process_one(dossier)
|
2022-11-25 15:43:00 +01:00
|
|
|
batch_operation.track_processed_dossier(true, dossier)
|
2022-11-18 16:59:46 +01:00
|
|
|
rescue => error
|
2022-11-25 15:43:00 +01:00
|
|
|
batch_operation.track_processed_dossier(false, dossier)
|
2022-11-18 16:59:46 +01:00
|
|
|
raise error
|
|
|
|
end
|
2022-11-25 15:43:00 +01:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
dossier.update(batch_operation_id: nil)
|
2022-11-18 16:59:46 +01:00
|
|
|
end
|
|
|
|
end
|