tech(refactor): inline PiecesJustificativesService.serialize_champs_as_pjs(object) within DossierSerializer

This commit is contained in:
Martin 2024-02-07 17:31:54 +01:00
parent 56ed901703
commit 83690529ca
2 changed files with 8 additions and 12 deletions

View file

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

View file

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