0
0
Fork 0

Change lists to reflect added and removed users retroactively (#32930)

This commit is contained in:
Eugen Rochko 2024-11-19 11:04:12 +01:00 committed by GitHub
parent f2976ec9a4
commit 2b5faa2ba3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 157 additions and 25 deletions

View file

@ -5,18 +5,42 @@ class MergeWorker
include Redisable
include DatabaseHelper
def perform(from_account_id, into_account_id)
def perform(from_account_id, into_id, type = 'home')
with_primary do
@from_account = Account.find(from_account_id)
end
case type
when 'home'
merge_into_home!(into_id)
when 'list'
merge_into_list!(into_id)
end
rescue ActiveRecord::RecordNotFound
true
end
private
def merge_into_home!(into_account_id)
with_primary do
@into_account = Account.find(into_account_id)
end
with_read_replica do
FeedManager.instance.merge_into_home(@from_account, @into_account)
end
rescue ActiveRecord::RecordNotFound
true
ensure
redis.del("account:#{into_account_id}:regeneration")
end
def merge_into_list!(into_list_id)
with_primary do
@into_list = List.find(into_list_id)
end
with_read_replica do
FeedManager.instance.merge_into_list(@from_account, @into_list)
end
end
end