perf(Instructeurs/Dossiers#demande): remove n+1
This commit is contained in:
parent
c072ee7226
commit
5cba847d10
2 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue