Merge pull request #10899 from mfo/US/fix-n-plus-one-on-instructeur-demande

tech: ETQ instructeur, ma page pour visualiser un dossier se charge plus vite
This commit is contained in:
mfo 2024-10-08 14:56:25 +00:00 committed by GitHub
commit 29500ebc48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -39,7 +39,7 @@ class DossierPreloader
def revisions(pj_template: false)
@revisions ||= ProcedureRevision.where(id: @dossiers.pluck(:revision_id).uniq)
.includes(types_de_champ_public: [], types_de_champ_private: [], types_de_champ: pj_template ? { piece_justificative_template_attachment: :blob } : [])
.includes(revision_types_de_champ: { parent: :type_de_champ }, types_de_champ_public: [], types_de_champ_private: [], types_de_champ: pj_template ? { piece_justificative_template_attachment: :blob } : [])
.index_by(&:id)
end

View file

@ -526,7 +526,8 @@ class TypeDeChamp < ApplicationRecord
end
def level_for_revision(revision)
rtdc = revision.revision_types_de_champ.includes(:type_de_champ, parent: :type_de_champ).find { |rtdc| rtdc.stable_id == stable_id }
rtdc = revision.revision_types_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