refactor(expert): no n+1 user on avis index
This commit is contained in:
parent
b2962c16e5
commit
9985cdccec
2 changed files with 6 additions and 5 deletions
|
@ -15,7 +15,8 @@ module Experts
|
||||||
def index
|
def index
|
||||||
avis = current_expert.avis
|
avis = current_expert.avis
|
||||||
.not_revoked
|
.not_revoked
|
||||||
.includes(dossier: [groupe_instructeur: :procedure])
|
.includes(:dossier)
|
||||||
|
.includes(procedure: { logo_attachment: :blob })
|
||||||
.not_hidden_by_administration
|
.not_hidden_by_administration
|
||||||
@avis_by_procedure = avis.to_a.group_by(&:procedure)
|
@avis_by_procedure = avis.to_a.group_by(&:procedure)
|
||||||
end
|
end
|
||||||
|
@ -30,7 +31,7 @@ module Experts
|
||||||
expert_avis = current_expert
|
expert_avis = current_expert
|
||||||
.avis
|
.avis
|
||||||
.not_revoked
|
.not_revoked
|
||||||
.includes(:dossier)
|
.includes(dossier: :user)
|
||||||
.not_hidden_by_administration
|
.not_hidden_by_administration
|
||||||
.where(dossiers: { groupe_instructeur: GroupeInstructeur.where(procedure: @procedure) })
|
.where(dossiers: { groupe_instructeur: GroupeInstructeur.where(procedure: @procedure) })
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,11 @@
|
||||||
- @avis.each do |avis|
|
- @avis.each do |avis|
|
||||||
%tr
|
%tr
|
||||||
%td.number-col
|
%td.number-col
|
||||||
= link_to(expert_avis_path(avis.procedure, avis), class: 'cell-link') do
|
= link_to(expert_avis_path(@procedure, avis), class: 'cell-link') do
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
#{avis.dossier.id}
|
#{avis.dossier.id}
|
||||||
%td= link_to(avis.dossier.user_email_for(:display), expert_avis_path(avis.procedure, avis), class: 'cell-link')
|
%td= link_to(avis.dossier.user_email_for(:display), expert_avis_path(@procedure, avis), class: 'cell-link')
|
||||||
%td= link_to(avis.procedure.libelle, expert_avis_path(avis.procedure, avis), class: 'cell-link')
|
%td= link_to(@procedure.libelle, expert_avis_path(@procedure, avis), class: 'cell-link')
|
||||||
= paginate @avis, views_prefix: 'shared'
|
= paginate @avis, views_prefix: 'shared'
|
||||||
- else
|
- else
|
||||||
%h2.empty-text Aucun avis
|
%h2.empty-text Aucun avis
|
||||||
|
|
Loading…
Reference in a new issue