Merge pull request #9586 from colinux/avis-perf

Expert: accélère les pages de liste d'avis et d'affichage des dossiers
This commit is contained in:
Colin Darie 2023-10-10 15:59:56 +00:00 committed by GitHub
commit 2eabbebfba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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,8 @@ module Experts
expert_avis = current_expert
.avis
.not_revoked
.includes(:dossier)
.includes(:procedure)
.includes(dossier: :user)
.not_hidden_by_administration
.where(dossiers: { groupe_instructeur: GroupeInstructeur.where(procedure: @procedure) })
@ -54,6 +56,7 @@ module Experts
end
def show
@dossier = dossier_with_champs
end
def instruction
@ -156,6 +159,8 @@ module Experts
end
def telecharger_pjs
@dossier = dossier_with_champs
files = ActiveStorage::DownloadableFile.create_list_from_dossiers(Dossier.where(id: @dossier.id), include_avis_for_expert: current_expert)
cleaned_files = ActiveStorage::DownloadableFile.cleanup_list_from_dossier(files)
@ -199,6 +204,11 @@ module Experts
@avis = current_expert.avis.find_by(id: params[:id])
redirect_to(expert_all_avis_path, flash: { alert: "Vous navez pas accès à cet avis." }) and return unless @avis
@dossier = @avis.dossier
set_sentry_dossier(@dossier)
end
def dossier_with_champs
DossierPreloader.load_one(@dossier, pj_template: false)
end
def avis_params