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:
Sam
2018-01-19 08:26:18 +11:00
parent 90a8ea617b
commit 12872d03be
8 changed files with 67 additions and 33 deletions

View File

@ -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