mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 04:25:50 +08:00
When a user uploads a new avatar, all their quoted posts are marked for rebaking in `Post.rebake_all_quoted_posts`. If a user has thousands of quoted posts, this SQL UPDATE can cause PostgreSQL statement timeouts. This commit moves the rebaking operation to a background job, allowing avatar uploads to complete in milliseconds. The rebaking still happens, but asynchronously in a Sidekiq worker without blocking the user.
12 lines
238 B
Ruby
Vendored
12 lines
238 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class RebakeQuotedPostsForUser < ::Jobs::Base
|
|
def execute(args)
|
|
user_id = args[:user_id]
|
|
return if user_id.blank?
|
|
|
|
Post.rebake_all_quoted_posts(user_id)
|
|
end
|
|
end
|
|
end
|