mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: N+1 query in suggested topics list.
This commit is contained in:
parent
ded9575c32
commit
604aaf8686
2 changed files with 4 additions and 4 deletions
|
@ -787,10 +787,12 @@ class TopicQuery
|
|||
end
|
||||
|
||||
def base_messages
|
||||
Topic
|
||||
query = Topic
|
||||
.where('topics.archetype = ?', Archetype.private_message)
|
||||
.joins("LEFT JOIN topic_users tu ON topics.id = tu.topic_id AND tu.user_id = #{@user.id.to_i}")
|
||||
.order('topics.bumped_at DESC')
|
||||
|
||||
query = query.includes(:tags) if SiteSetting.tagging_enabled
|
||||
query.order('topics.bumped_at DESC')
|
||||
end
|
||||
|
||||
def random_suggested(topic, count, excluded_topic_ids=[])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue