Migrate `BlockDomainService` notification job enqueueing to Sidekiq's `perform_bulk` for efficiency (#33897)

pull/2968/head^2
Nicholas La Roux 2025-02-12 21:48:09 +09:00 committed by GitHub
parent 447d12aa08
commit 7a50fd8849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -47,10 +47,14 @@ class BlockDomainService < BaseService
def notify_of_severed_relationships! def notify_of_severed_relationships!
return if @domain_block_event.nil? return if @domain_block_event.nil?
# TODO: check how efficient that query is, also check `push_bulk`/`perform_bulk` # find_in_batches and perform_bulk both default to batches of 1000
@domain_block_event.affected_local_accounts.reorder(nil).find_each do |account| @domain_block_event.affected_local_accounts.reorder(nil).find_in_batches do |accounts|
event = AccountRelationshipSeveranceEvent.create!(account: account, relationship_severance_event: @domain_block_event) notification_jobs_args = accounts.map do |account|
LocalNotificationWorker.perform_async(account.id, event.id, 'AccountRelationshipSeveranceEvent', 'severed_relationships') event = AccountRelationshipSeveranceEvent.create!(account:, relationship_severance_event: @domain_block_event)
[account.id, event.id, 'AccountRelationshipSeveranceEvent', 'severed_relationships']
end
LocalNotificationWorker.perform_bulk(notification_jobs_args)
end end
end end