discourse/app/jobs/regular/rebake_quoted_posts_for_user.rb
Amanda Alves Branquinho 13492ae613
FIX: Move quoted post rebaking on avatar upload to a background job (#40231)
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.
2026-05-22 13:27:52 -03:00

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