merge_worker.rb 531 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. class MergeWorker
  3. include Sidekiq::Worker
  4. include Redisable
  5. include DatabaseHelper
  6. def perform(from_account_id, into_account_id)
  7. with_primary do
  8. @from_account = Account.find(from_account_id)
  9. @into_account = Account.find(into_account_id)
  10. end
  11. with_read_replica do
  12. FeedManager.instance.merge_into_home(@from_account, @into_account)
  13. end
  14. rescue ActiveRecord::RecordNotFound
  15. true
  16. ensure
  17. redis.del("account:#{into_account_id}:regeneration")
  18. end
  19. end