DEV: Reduce an additional DB query in TopicView for ignored users. (#14619)

`TopicView#first_post_id` does a pluck which we can avoid because the
first post will always have a `Post#post_number` of 1.
This commit is contained in:
Alan Guo Xiang Tan 2021-10-18 09:58:13 +08:00 committed by GitHub
parent 779eeb65b3
commit 235d069300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -789,7 +789,7 @@ class TopicView
ignored_user_ids = DB.query_single(sql, current_user_id: @user.id)
if ignored_user_ids.present?
@filtered_posts = @filtered_posts.where.not("user_id IN (?) AND posts.id <> ?", ignored_user_ids, first_post_id)
@filtered_posts = @filtered_posts.where.not("user_id IN (?) AND posts.post_number != 1", ignored_user_ids)
@contains_gaps = true
end
end