service and serializer

This commit is contained in:
Kara Diaby 2024-02-13 07:10:22 +00:00
parent b69d8249c5
commit bf622eb3ed
2 changed files with 2 additions and 6 deletions

View file

@ -2,13 +2,9 @@ class CommentaireSerializer < ActiveModel::Serializer
attributes :email, attributes :email,
:body, :body,
:created_at, :created_at,
:attachment :piece_jointe_attachments
def created_at def created_at
object.created_at&.in_time_zone('UTC') object.created_at&.in_time_zone('UTC')
end end
def attachment
object.file_url
end
end end

View file

@ -161,7 +161,7 @@ class PiecesJustificativesService
def pjs_for_commentaires(dossiers) def pjs_for_commentaires(dossiers)
commentaire_id_dossier_id = Commentaire commentaire_id_dossier_id = Commentaire
.joins(:piece_jointe_attachment) .joins(:piece_jointe_attachments)
.where(dossier: dossiers) .where(dossier: dossiers)
.pluck(:id, :dossier_id) .pluck(:id, :dossier_id)
.to_h .to_h