From b12627f074443edc2e3125f44857ab33556618fc Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 15 May 2024 17:57:02 +0200 Subject: [PATCH] fix(dossier): fix n+1 on header sections --- app/models/type_de_champ.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 65c743350..ea2de7468 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -523,7 +523,7 @@ class TypeDeChamp < ApplicationRecord end def level_for_revision(revision) - rtdc = revision.revision_types_de_champ.find { |rtdc| rtdc.stable_id == stable_id } + rtdc = revision.revision_types_de_champ.includes(:type_de_champ, parent: :type_de_champ).find { |rtdc| rtdc.stable_id == stable_id } if rtdc.child? header_section_level_value.to_i + rtdc.parent.type_de_champ.current_section_level(revision) elsif header_section_level_value