refactor(dossier): use new champs_for_revision method
This commit is contained in:
parent
3e296fc75c
commit
1850d80b82
16 changed files with 54 additions and 66 deletions
|
@ -23,16 +23,6 @@ class ProcedureArchiveService
|
|||
end
|
||||
end
|
||||
|
||||
def self.procedure_files_size(procedure)
|
||||
dossiers_files_size(procedure.dossiers)
|
||||
end
|
||||
|
||||
def self.dossiers_files_size(dossiers)
|
||||
dossiers.map do |dossier|
|
||||
liste_pieces_justificatives_for_archive(dossier).sum(&:byte_size)
|
||||
end.sum
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def zip_root_folder(archive)
|
||||
|
@ -43,19 +33,4 @@ class ProcedureArchiveService
|
|||
archive.id
|
||||
].join("-")
|
||||
end
|
||||
|
||||
def self.attachments_from_champs_piece_justificative(champs)
|
||||
champs
|
||||
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) }
|
||||
.map(&:piece_justificative_file)
|
||||
.filter(&:attached?)
|
||||
end
|
||||
|
||||
def self.liste_pieces_justificatives_for_archive(dossier)
|
||||
champs_blocs_repetables = dossier.champs_public
|
||||
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
|
||||
.flat_map(&:champs)
|
||||
|
||||
attachments_from_champs_piece_justificative(champs_blocs_repetables + dossier.champs_public)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue