From abae71c0605eaa8b0fa0d828e49978559568a0c5 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 18 Feb 2017 05:45:36 -0600 Subject: [PATCH] layouts/default.html.erb: optimize dmail notice sql. * CurrentUser.dmail_count caused an unnecessary COUNT(*). * CurrentUser.dmails.unread.present? caused *all* unread dmails to be loaded. We want to only load the first one. --- app/views/layouts/default.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 95fd2c3df..9ef528a5f 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -85,7 +85,7 @@ <%= render "users/ban_notice" %> <% end %> - <% if CurrentUser.dmail_count.present? && CurrentUser.dmails.unread.present? && cookies[:hide_dmail_notice].to_i != CurrentUser.dmails.unread.first.id %> + <% if CurrentUser.has_mail? && CurrentUser.dmails.unread.first.present? && cookies[:hide_dmail_notice].to_i != CurrentUser.dmails.unread.first.id %> <%= render "users/dmail_notice" %> <% end %>