mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:12:26 +08:00
FIX: N+1 query in suggested topics list.
This commit is contained in:
parent
ded9575c32
commit
604aaf8686
|
@ -46,8 +46,6 @@ class TopicList
|
|||
if @opts[:category]
|
||||
@category = Category.find_by(id: @opts[:category_id])
|
||||
end
|
||||
|
||||
preloaded_custom_fields << DiscourseTagging::TAGS_FIELD_NAME if SiteSetting.tagging_enabled
|
||||
end
|
||||
|
||||
def tags
|
||||
|
|
|
@ -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…
Reference in New Issue
Block a user