move create_list_of_attachments

This commit is contained in:
simon lehericey 2022-04-04 17:45:10 +02:00
parent 1f98f75ccc
commit bd0b88a410
2 changed files with 8 additions and 7 deletions

View file

@ -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)

View file

@ -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) }