demarches-normaliennes/app/jobs/batch_operation_process_one_job.rb
mfo 0cfa9d6719
fix(batch): this is a hotfix, please be nice we just want to allow our
infra to deal with BatchOperation when their is a big load
2024-09-24 09:34:37 +02:00

23 lines
727 B
Ruby

# frozen_string_literal: true
class BatchOperationProcessOneJob < ApplicationJob
queue_as :mailer # hotfix
retry_on StandardError, attempts: 1 # default 5, for now no retryable behavior
def perform(batch_operation, dossier)
dossier = batch_operation.dossiers_safe_scope.find(dossier.id)
begin
ActiveRecord::Base.transaction do
batch_operation.process_one(dossier)
batch_operation.track_processed_dossier(true, dossier)
end
rescue => error
ActiveRecord::Base.transaction do
batch_operation.track_processed_dossier(false, dossier)
end
raise error
end
rescue ActiveRecord::RecordNotFound
dossier.update_column(:batch_operation_id, nil)
end
end