PERF: Make mega topics work without a stream.

There are tradeoffs that we took here. For the complete
story see
https://meta.discourse.org/t/performance-improvements-on-long-topics/30187/27?u=tgxworld.
This commit is contained in:
Guo Xiang Tan
2018-07-11 15:41:26 +08:00
parent de4d4747c4
commit 258e9e35ca
11 changed files with 473 additions and 69 deletions

View File

@ -177,10 +177,26 @@ class TopicsController < ApplicationController
def posts
params.require(:topic_id)
params.permit(:post_ids)
params.permit(:post_ids, :post_number, :username_filters, :filter)
@topic_view = TopicView.new(params[:topic_id], current_user, post_ids: params[:post_ids])
render_json_dump(TopicViewPostsSerializer.new(@topic_view, scope: guardian, root: false, include_raw: !!params[:include_raw]))
default_options = {
filter_post_number: params[:post_number],
post_ids: params[:post_ids],
asc: ActiveRecord::Type::Boolean.new.deserialize(params[:asc]),
filter: params[:filter]
}
if (username_filters = params[:username_filters]).present?
default_options[:username_filters] = username_filters.split(',')
end
@topic_view = TopicView.new(params[:topic_id], current_user, default_options)
render_json_dump(TopicViewPostsSerializer.new(@topic_view,
scope: guardian,
root: false,
include_raw: !!params[:include_raw]
))
end
def excerpts