comments: minimize sql queries.
Certain parts of comment rendering triggered sql queries that we didn't really need to do. Rework things to avoid this. * Preload comment creators in order to display commenter names with link_to_user. * Preload comment votes in order to display "undo vote" links. Only preload votes for members since anonymous users can't vote and don't have "undo vote" links. * Rework various conditionals to do the filtering in Ruby so that we avoid issuing any extra queries in sql. * Avoid issuing any queries at all when the post doesn't have any comments (when last_commented_at is blank).
This commit is contained in:
@@ -120,7 +120,7 @@
|
||||
<% if !CurrentUser.user.is_builder? %>
|
||||
<h2>Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.</h2>
|
||||
<% end %>
|
||||
<%= render "comments/partials/index/list", :comments => @post.comments.visible(CurrentUser.user).includes(:creator), :post => @post, :show_header => false %>
|
||||
<%= render "comments/partials/index/list", comments: @comments, post: @post, page: :post %>
|
||||
</section>
|
||||
|
||||
<section id="notes" style="display: none;">
|
||||
|
||||
Reference in New Issue
Block a user