Merge pull request #10421 from tchak/fix-some-n+1

fix(dossier): fix n+1 on header sections
This commit is contained in:
Paul Chavard 2024-05-15 16:12:50 +00:00 committed by GitHub
commit 1d2550e69d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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