fix(dossier): fix n+1 on header sections

This commit is contained in:
Paul Chavard 2024-05-15 17:57:02 +02:00
parent 241da41c4c
commit b12627f074

View file

@ -523,7 +523,7 @@ class TypeDeChamp < ApplicationRecord
end end
def level_for_revision(revision) 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? if rtdc.child?
header_section_level_value.to_i + rtdc.parent.type_de_champ.current_section_level(revision) header_section_level_value.to_i + rtdc.parent.type_de_champ.current_section_level(revision)
elsif header_section_level_value elsif header_section_level_value