From 1505d45be19eae4212a070e31d144fa0077b7fd5 Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Fri, 20 Sep 2019 12:42:10 +0200 Subject: [PATCH] Optimize notifications queries for badges by using exists?, not present? `ActiveRecord::Relation.exists?` yields a SQL EXISTS query, while `present?` is a method of Enumerable, which needs the actual result array to be queried. --- app/views/instructeurs/procedures/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index 04dd70c5e..302ce3a95 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -24,13 +24,13 @@ instructeur_procedure_path(@procedure, statut: 'suivis'), active: @statut == 'suivis', badge: @followed_dossiers.count, - notification: current_instructeur.notifications_for_procedure(@procedure, :en_cours).present?) + notification: current_instructeur.notifications_for_procedure(@procedure, :en_cours).exists?) = tab_item(t('pluralize.processed', count: @termines_dossiers.count), instructeur_procedure_path(@procedure, statut: 'traites'), active: @statut == 'traites', badge: @termines_dossiers.count, - notification: current_instructeur.notifications_for_procedure(@procedure, :termine).present?) + notification: current_instructeur.notifications_for_procedure(@procedure, :termine).exists?) = tab_item('tous les dossiers', instructeur_procedure_path(@procedure, statut: 'tous'),