comments: fix N+1 query when loading comment votes.
Doing both `@comments.includes(:votes)` and `comment.votes.active` forced votes to be loaded twice.
This commit is contained in:
@@ -11,7 +11,7 @@ class CommentSectionComponent < ApplicationComponent
|
||||
|
||||
@comments = @post.comments.order(id: :asc)
|
||||
@comments = @comments.includes(:creator)
|
||||
@comments = @comments.includes(:votes) if !current_user.is_anonymous?
|
||||
@comments = @comments.includes(:active_votes) if !current_user.is_anonymous?
|
||||
@comments = @comments.includes(:pending_moderation_reports) if policy(ModerationReport).can_see_moderation_reports?
|
||||
@comments = @comments.last(limit) if limit.present?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user