PERF: creating a post would cause an N+1 (#21768)
In the case where the `@topic_view` is not present we were fetching users without including `:user_status`, which would cause an N+1
This commit is contained in:
parent
2a748ff5cb
commit
a6a5c1b69b
|
@ -570,7 +570,9 @@ class PostSerializer < BasicPostSerializer
|
|||
if @topic_view && (mentioned_users = @topic_view.mentioned_users[object.id])
|
||||
mentioned_users
|
||||
else
|
||||
User.where(username: object.mentions)
|
||||
query = User
|
||||
query = query.includes(:user_status) if SiteSetting.enable_user_status
|
||||
query = query.where(username: object.mentions)
|
||||
end
|
||||
|
||||
users.map { |user| BasicUserWithStatusSerializer.new(user, root: false) }
|
||||
|
|
Loading…
Reference in New Issue