diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb index eca5bbb5a4e56..0cf574ca2fb5c 100644 --- a/app/services/suspend_account_service.rb +++ b/app/services/suspend_account_service.rb @@ -25,7 +25,7 @@ def purge_content @account.active_relationships, @account.passive_relationships ].each do |association| - destroy_all_in_stand_alone_transaction(association) + destroy_all(association) end end @@ -39,10 +39,10 @@ def purge_profile end def unsubscribe_push_subscribers - destroy_all_in_stand_alone_transaction(@account.subscriptions) + destroy_all(@account.subscriptions) end - def destroy_all_in_stand_alone_transaction(association) - association.find_each(&:destroy) + def destroy_all(association) + association.in_batches.destroy_all end end diff --git a/spec/services/suspend_account_service_spec.rb b/spec/services/suspend_account_service_spec.rb index ec43bb008139a..1cb647e8dafa2 100644 --- a/spec/services/suspend_account_service_spec.rb +++ b/spec/services/suspend_account_service_spec.rb @@ -15,7 +15,7 @@ let!(:passive_relationship) { Fabricate(:follow, target_account: account) } let!(:subscription) { Fabricate(:subscription, account: account) } - it 'destroys related records' do + it 'deletes associated records' do is_expected.to change { [ account.statuses,