refactor(expert): no n+1 user on avis index

This commit is contained in:
Colin Darie 2023-10-10 14:57:05 +02:00
parent b2962c16e5
commit 9985cdccec
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
2 changed files with 6 additions and 5 deletions

View file

@ -15,7 +15,8 @@ module Experts
def index
avis = current_expert.avis
.not_revoked
.includes(dossier: [groupe_instructeur: :procedure])
.includes(:dossier)
.includes(procedure: { logo_attachment: :blob })
.not_hidden_by_administration
@avis_by_procedure = avis.to_a.group_by(&:procedure)
end
@ -30,7 +31,7 @@ module Experts
expert_avis = current_expert
.avis
.not_revoked
.includes(:dossier)
.includes(dossier: :user)
.not_hidden_by_administration
.where(dossiers: { groupe_instructeur: GroupeInstructeur.where(procedure: @procedure) })

View file

@ -36,11 +36,11 @@
- @avis.each do |avis|
%tr
%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
#{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.procedure.libelle, 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(@procedure.libelle, expert_avis_path(@procedure, avis), class: 'cell-link')
= paginate @avis, views_prefix: 'shared'
- else
%h2.empty-text Aucun avis