Avoid n+1 when loading types de champ in to the editor

This commit is contained in:
Paul Chavard 2019-02-04 16:43:26 +01:00 committed by simon lehericey
parent fbd10f7758
commit 2754dc9c9e

View file

@ -89,6 +89,9 @@ module ProcedureHelper
.merge(include: TYPES_DE_CHAMP_INCLUDE.merge(types_de_champ: TYPES_DE_CHAMP_BASE))
def types_de_champ_as_json(types_de_champ)
types_de_champ.as_json(TYPES_DE_CHAMP)
types_de_champ.includes(:drop_down_list,
piece_justificative_template_attachment: :blob,
types_de_champ: [:drop_down_list, piece_justificative_template_attachment: :blob])
.as_json(TYPES_DE_CHAMP)
end
end