mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
PERF: run post timings in background
This means that if a very large amount of registered users hit a single topic we will handle it gracefully, even if db gets slow.
This commit is contained in:
@ -585,14 +585,22 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def timings
|
||||
PostTiming.process_timings(
|
||||
current_user,
|
||||
topic_params[:topic_id].to_i,
|
||||
topic_params[:topic_time].to_i,
|
||||
(topic_params[:timings].to_h || {}).map { |post_number, t| [post_number.to_i, t.to_i] },
|
||||
mobile: view_context.mobile_view?
|
||||
)
|
||||
render body: nil
|
||||
allowed_params = topic_params
|
||||
|
||||
topic_id = allowed_params[:topic_id].to_i
|
||||
topic_time = allowed_params[:topic_time].to_i
|
||||
timings = allowed_params[:timings].to_h || {}
|
||||
|
||||
hijack do
|
||||
PostTiming.process_timings(
|
||||
current_user,
|
||||
topic_id,
|
||||
topic_time,
|
||||
timings.map { |post_number, t| [post_number.to_i, t.to_i] },
|
||||
mobile: view_context.mobile_view?
|
||||
)
|
||||
render body: nil
|
||||
end
|
||||
end
|
||||
|
||||
def feed
|
||||
|
Reference in New Issue
Block a user