mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: do not include suggested topics when loading new posts
When a new post is triggered via message bus post stream will attempt to load it, previously the `/topic/TOPIC_ID/posts.json` would unconditionally include suggested topics, this caused excessive load on the server. New pattern defaults to exclude suggested and related topics from this API unless people explicitly ask for suggested.
This commit is contained in:
@@ -51,6 +51,9 @@ class TopicView
|
||||
@post_number = [@post_number.to_i, 1].max
|
||||
@page = [@page.to_i, 1].max
|
||||
|
||||
@include_suggested = options.fetch(:include_suggested) { true }
|
||||
@include_related = options.fetch(:include_related) { true }
|
||||
|
||||
@chunk_size =
|
||||
case
|
||||
when @print then TopicView.print_chunk_size
|
||||
@@ -402,11 +405,19 @@ class TopicView
|
||||
end
|
||||
|
||||
def suggested_topics
|
||||
@suggested_topics ||= TopicQuery.new(@user).list_suggested_for(topic, pm_params: pm_params)
|
||||
if @include_suggested
|
||||
@suggested_topics ||= TopicQuery.new(@user).list_suggested_for(topic, pm_params: pm_params)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def related_messages
|
||||
@related_messages ||= TopicQuery.new(@user).list_related_for(topic, pm_params: pm_params)
|
||||
if @include_related
|
||||
@related_messages ||= TopicQuery.new(@user).list_related_for(topic, pm_params: pm_params)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# This is pending a larger refactor, that allows custom orders
|
||||
|
||||
Reference in New Issue
Block a user