From 83690529ca2b3caff71351359599c278ed59be41 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 7 Feb 2024 17:31:54 +0100 Subject: [PATCH] tech(refactor): inline PiecesJustificativesService.serialize_champs_as_pjs(object) within DossierSerializer --- app/serializers/dossier_serializer.rb | 9 ++++++++- app/services/pieces_justificatives_service.rb | 11 ----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index e801ee6dc..81e783bba 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -55,7 +55,14 @@ class DossierSerializer < ActiveModel::Serializer end def pieces_justificatives - PiecesJustificativesService.serialize_champs_as_pjs(object) + object.champs_public.filter { |champ| champ.type_de_champ.old_pj }.map do |champ| + { + created_at: champ.created_at&.in_time_zone('UTC'), + type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id], + content_url: champ.for_api, + user: champ.dossier.user + } + end.flatten end def attestation diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index f889b140e..d02341a3f 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -48,17 +48,6 @@ class PiecesJustificativesService end end - def self.serialize_champs_as_pjs(dossier) - dossier.champs_public.filter { |champ| champ.type_de_champ.old_pj }.map do |champ| - { - created_at: champ.created_at&.in_time_zone('UTC'), - type_de_piece_justificative_id: champ.type_de_champ.old_pj[:stable_id], - content_url: champ.for_api, - user: champ.dossier.user - } - end.flatten - end - def self.generate_dossier_export(dossiers, include_infos_administration: false, include_avis_for_expert: false) return [] if dossiers.empty?