Use better method of querying the moderation reports for an instance
The use of any? and count was forcing new SQL requests for each statement. Instead, present? and length were used which act on the reports once loaded. Although unneeded, the comment and forum views were changed as well for consistency.
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
<%= render "comments/partials/index/header", :post => post %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_moderator? && post.moderation_reports.any? %>
|
||||
<% if CurrentUser.is_moderator? && post.moderation_reports.present? %>
|
||||
<div class="row moderation-comments-notice">
|
||||
<span class="info" id="moderation-comments-notice-for-<%= post.id %>">
|
||||
This post has comments reported for moderation! (<%= post.moderation_reports.count %> <%= (post.moderation_reports.count == 1 ? "report" : "reports") %>)
|
||||
This post has comments reported for moderation! (<%= post.moderation_reports.length %> <%= (post.moderation_reports.length == 1 ? "report" : "reports") %>)
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user