avoid extra COUNT queries for loaded Relations

This commit is contained in:
Peter Bhat Harkins 2022-03-02 08:53:33 -06:00
parent 9a60692dce
commit 9faf46b0cf
4 changed files with 13 additions and 3 deletions

View File

@ -3,7 +3,7 @@
Requested Hats
</div>
<% if @hat_requests.count == 0 %>
<% if @hat_requests.length == 0 %>
No hat requests.
<% else %>
<% @hat_requests.each_with_index do |hr,x| %>

View File

@ -0,0 +1,10 @@
<div class="box">
Stories with <a href="/tags">tags</a> in the
<% @categories.each do |c| %>
<%= link_to c.category, category_path(c) %>
<% end %>
<%= "category".pluralize(@categories) %>
<%= render(partial: 'categories/multi_category_tip') if @categories.length == 1 %>
</div>

View File

@ -38,7 +38,7 @@
<% end %>
</tr>
<% end %>
<% if @invitation_requests.count == 0 %>
<% if @invitation_requests.length == 0 %>
<tr>
<td colspan=<%= @user.is_moderator?? 5 : 4 %> align="center"><span
class="na">No invitation requests</span></td>

View File

@ -30,7 +30,7 @@
<p class="help">No replies to show.</p>
<% end %>
<% if @replies.count > RepliesController::REPLIES_PER_PAGE && @filter != 'unread'%>
<% if @replies.length > RepliesController::REPLIES_PER_PAGE && @filter != 'unread'%>
<div class="morelink">
<% if @page && @page > 1 %>
<a href="/replies<%= @page == 2 ? "" : "/page/#{@page - 1}" %>">&lt;&lt;