Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

Commit

Permalink
Delete records in smaller transaction (mastodon#2802)
Browse files Browse the repository at this point in the history
  • Loading branch information
alpaca-tc committed May 8, 2017
1 parent e9ec6d6 commit 2f3de9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/services/suspend_account_service.rb
Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion spec/services/suspend_account_service_spec.rb
Expand Up @@ -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,
Expand Down

0 comments on commit 2f3de9d

Please sign in to comment.