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.
This commit is contained in:
evazion
2017-02-18 05:45:36 -06:00
parent d9349704c7
commit abae71c060

View File

@@ -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 %>