From 437e871f798eab4a8edcc9da25d7a12b74431061 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 1 Apr 2022 16:21:38 +0200 Subject: [PATCH] extract operation_logs_and_signatures method --- app/services/pieces_justificatives_service.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index ca5554518..a490c9bf5 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -146,13 +146,19 @@ class PiecesJustificativesService ].flatten.compact if !for_expert - bill_signatures = dossier.dossier_operation_logs.filter_map(&:bill_signature).uniq - pjs += [ - dossier.dossier_operation_logs.map(&:serialized), - bill_signatures.map(&:serialized), - bill_signatures.map(&:signature) - ].flatten.compact + pjs += operation_logs_and_signatures(dossier) end + pjs end + + def self.operation_logs_and_signatures(dossier) + bill_signatures = dossier.dossier_operation_logs.filter_map(&:bill_signature).uniq + + [ + dossier.dossier_operation_logs.map(&:serialized), + bill_signatures.map(&:serialized), + bill_signatures.map(&:signature) + ].flatten.compact + end end