cache procedure_ids_with_notifications to avoid seeking the AR cache by going through the stack

This commit is contained in:
simon lehericey 2020-09-10 21:03:50 +02:00 committed by LeSim (Rebase PR Action)
parent e4de522b48
commit b124579681
3 changed files with 8 additions and 3 deletions

View file

@ -37,6 +37,9 @@ module Instructeurs
'dossiers' => @dossiers_count_per_procedure.sum { |_, v| v },
'archivés' => @dossiers_archived_count_per_procedure.sum { |_, v| v }
}
@procedure_ids_en_cours_with_notifications = current_instructeur.procedure_ids_with_notifications(:en_cours)
@procedure_ids_termines_with_notifications = current_instructeur.procedure_ids_with_notifications(:termine)
end
def show

View file

@ -21,7 +21,7 @@
%li
%object
= link_to(instructeur_procedure_path(p, statut: 'suivis')) do
- if current_instructeur.procedure_ids_with_notifications(:en_cours).include?(p.id)
- if procedure_ids_en_cours_with_notifications.include?(p.id)
%span.notifications{ 'aria-label': "notifications" }
- followed_count = followed_dossiers_count_per_procedure[p.id] || 0
.stats-number
@ -31,7 +31,7 @@
%li
%object
= link_to(instructeur_procedure_path(p, statut: 'traites')) do
- if current_instructeur.procedure_ids_with_notifications(:termine).include?(p.id)
- if procedure_ids_termines_with_notifications.include?(p.id)
%span.notifications{ 'aria-label': "notifications" }
- termines_count = dossiers_termines_count_per_procedure[p.id] || 0
.stats-number

View file

@ -9,4 +9,6 @@
dossiers_a_suivre_count_per_procedure: @dossiers_a_suivre_count_per_procedure,
dossiers_archived_count_per_procedure: @dossiers_archived_count_per_procedure,
dossiers_termines_count_per_procedure: @dossiers_termines_count_per_procedure,
followed_dossiers_count_per_procedure: @followed_dossiers_count_per_procedure }
followed_dossiers_count_per_procedure: @followed_dossiers_count_per_procedure,
procedure_ids_en_cours_with_notifications: @procedure_ids_en_cours_with_notifications,
procedure_ids_termines_with_notifications: @procedure_ids_termines_with_notifications }