2021-04-29 17:29:47 +02:00
|
|
|
class ArchiveCreationJob < ApplicationJob
|
2021-11-29 15:43:51 +01:00
|
|
|
queue_as :archives
|
2021-06-24 21:01:59 +02:00
|
|
|
|
2022-06-23 13:51:58 +02:00
|
|
|
def perform(procedure, archive, administrateur_or_instructeur)
|
2022-03-30 16:19:14 +02:00
|
|
|
archive.restart! if archive.failed? # restart for AASM
|
2021-04-29 17:29:47 +02:00
|
|
|
ProcedureArchiveService
|
|
|
|
.new(procedure)
|
2022-06-23 13:51:58 +02:00
|
|
|
.make_and_upload_archive(archive)
|
2022-03-30 16:19:14 +02:00
|
|
|
archive.make_available!
|
2022-06-23 13:51:58 +02:00
|
|
|
UserMailer.send_archive(administrateur_or_instructeur, procedure, archive).deliver_later
|
2022-03-30 16:19:14 +02:00
|
|
|
rescue => e
|
|
|
|
archive.fail! # fail for observability
|
|
|
|
raise e # re-raise for retryable behaviour
|
2021-04-29 17:29:47 +02:00
|
|
|
end
|
|
|
|
end
|