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 %>
|
<%= render "comments/partials/index/header", :post => post %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if CurrentUser.is_moderator? && post.moderation_reports.any? %>
|
<% if CurrentUser.is_moderator? && post.moderation_reports.present? %>
|
||||||
<div class="row moderation-comments-notice">
|
<div class="row moderation-comments-notice">
|
||||||
<span class="info" id="moderation-comments-notice-for-<%= post.id %>">
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
<%- # moderation_reports %>
|
<%- # moderation_reports %>
|
||||||
|
|
||||||
<div class="list-of-forum-posts list-of-messages">
|
<div class="list-of-forum-posts list-of-messages">
|
||||||
<% if CurrentUser.is_moderator? && moderation_reports.any? %>
|
<% if CurrentUser.is_moderator? && moderation_reports.present? %>
|
||||||
<div class="row moderation-forums-notice">
|
<div class="row moderation-forums-notice">
|
||||||
<span class="info" id="moderation-forums-notice-for-topic">
|
<span class="info" id="moderation-forums-notice-for-topic">
|
||||||
This topic has forum posts reported for moderation! (<%= moderation_reports.count %> <%= (moderation_reports.count == 1 ? "report" : "reports") %>)
|
This topic has forum posts reported for moderation! (<%= moderation_reports.length %> <%= (moderation_reports.length == 1 ? "report" : "reports") %>)
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
<div id="a-show">
|
<div id="a-show">
|
||||||
<h1><%= link_to_user @user %></h1>
|
<h1><%= link_to_user @user %></h1>
|
||||||
|
|
||||||
<% if !@user.is_moderator? && CurrentUser.is_moderator? && @user.moderation_reports.any? %>
|
<% if !@user.is_moderator? && CurrentUser.is_moderator? && @user.moderation_reports.present? %>
|
||||||
<div class="moderation-users-notice">
|
<div class="moderation-users-notice">
|
||||||
<span class="info" id="moderation-users-notice-for-<%= @user.id %>">
|
<span class="info" id="moderation-users-notice-for-<%= @user.id %>">
|
||||||
This user has been reported for moderation! (<%= @user.moderation_reports.count %> <%= (@user.moderation_reports.count == 1 ? "report" : "reports") %>)
|
This user has been reported for moderation! (<%= @user.moderation_reports.length %> <%= (@user.moderation_reports.length == 1 ? "report" : "reports") %>)
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user