From 2754dc9c9e5805164ef59aae2dc295adc684c267 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 4 Feb 2019 16:43:26 +0100 Subject: [PATCH] Avoid n+1 when loading types de champ in to the editor --- app/helpers/procedure_helper.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb index 443626b8e..fe3395201 100644 --- a/app/helpers/procedure_helper.rb +++ b/app/helpers/procedure_helper.rb @@ -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