Change lists to reflect added and removed users retroactively (#32930)
This commit is contained in:
parent
f2976ec9a4
commit
2b5faa2ba3
12 changed files with 157 additions and 25 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue