Skip to content

Commit

Permalink
Merge pull request #10899 from mfo/US/fix-n-plus-one-on-instructeur-d…
Browse files Browse the repository at this point in the history
…emande

tech: ETQ instructeur, ma page pour visualiser un dossier se charge plus vite
  • Loading branch information
mfo authored Oct 8, 2024
2 parents c072ee7 + 5cba847 commit 29500eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/dossier_preloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def self.load_one(dossier, pj_template: false)

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

Expand Down
3 changes: 2 additions & 1 deletion app/models/type_de_champ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ def current_section_level(revision)
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
Expand Down

0 comments on commit 29500eb

Please sign in to comment.