Merge pull request #639 from sgmap/n_plus_one_hunt

N plus one hunt
This commit is contained in:
Mathieu Magnin 2017-08-25 11:10:29 +02:00
commit f15093ac35
3 changed files with 12 additions and 5 deletions

View file

@ -27,19 +27,26 @@ module NewGestionnaire
@a_suivre_dossiers = procedure
.dossiers
.includes(:user)
.without_followers
.en_cours
@followed_dossiers = current_gestionnaire
.followed_dossiers
.includes(:user)
.where(procedure: @procedure)
.en_cours
@termines_dossiers = procedure.dossiers.termine
@followed_dossiers_id = current_gestionnaire
.followed_dossiers
.where(procedure: @procedure)
.pluck(:id)
@all_state_dossiers = procedure.dossiers.all_state
@termines_dossiers = procedure.dossiers.includes(:user).termine
@archived_dossiers = procedure.dossiers.archived
@all_state_dossiers = procedure.dossiers.includes(:user).all_state
@archived_dossiers = procedure.dossiers.includes(:user).archived
@statut = params[:statut].present? ? params[:statut] : 'a-suivre'

View file

@ -1,5 +1,5 @@
- if dossier.en_construction_ou_instruction?
- if current_gestionnaire.follow?(dossier)
- if dossier_is_followed
= link_to unfollow_dossier_path(procedure, dossier), method: :patch, class: 'button' do
%i.unfollow>
ne plus suivre

View file

@ -47,6 +47,6 @@
%td.status-col
= link_to(dossier_path(@procedure, dossier), class: 'big-link') do
= render partial: 'status', locals: { dossier: dossier }
%td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier }
%td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) }
- else
%h2 Aucun dossier