diff --git a/app/lib/active_storage/downloadable_file.rb b/app/lib/active_storage/downloadable_file.rb index eca681943..8c3855ad4 100644 --- a/app/lib/active_storage/downloadable_file.rb +++ b/app/lib/active_storage/downloadable_file.rb @@ -11,6 +11,12 @@ class ActiveStorage::DownloadableFile end end + def self.create_list_from_dossiers(dossiers) + dossiers.flat_map do |dossier| + create_list_from_dossier(dossier) + end + end + private def self.timestamped_filename(attachment) diff --git a/app/services/procedure_archive_service.rb b/app/services/procedure_archive_service.rb index 9f244c06c..31f0786f6 100644 --- a/app/services/procedure_archive_service.rb +++ b/app/services/procedure_archive_service.rb @@ -25,7 +25,8 @@ class ProcedureArchiveService dossiers.processed_in_month(archive.month) end - attachments = create_list_of_attachments(dossiers) + attachments = ActiveStorage::DownloadableFile.create_list_from_dossiers(dossiers) + download_and_zip(archive, attachments) do |zip_filepath| ArchiveUploader.new(procedure: @procedure, archive: archive, filepath: zip_filepath) .upload @@ -72,12 +73,6 @@ class ProcedureArchiveService "procedure-#{@procedure.id}-#{archive.id}" end - def create_list_of_attachments(dossiers) - dossiers.flat_map do |dossier| - ActiveStorage::DownloadableFile.create_list_from_dossier(dossier) - end - end - def self.attachments_from_champs_piece_justificative(champs) champs .filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) }