demarches-normaliennes/app/jobs/archive_creation_job.rb
2022-03-31 13:35:49 +02:00

15 lines
503 B
Ruby

class ArchiveCreationJob < ApplicationJob
queue_as :archives
def perform(procedure, archive, instructeur)
archive.restart! if archive.failed? # restart for AASM
ProcedureArchiveService
.new(procedure)
.make_and_upload_archive(archive, instructeur)
archive.make_available!
InstructeurMailer.send_archive(instructeur, procedure, archive).deliver_later
rescue => e
archive.fail! # fail for observability
raise e # re-raise for retryable behaviour
end
end