about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-12-23 16:43:11 +0100
committerGitHub <noreply@github.com>2020-12-23 16:43:11 +0100
commitde57efd055c8c6af9e6e2aa450cea790546aabbc (patch)
tree0045c3f35bb15153740f79e29270574c5c8fb36a /app
parent473abc35a19771304839dc57dc41ef309a826658 (diff)
Fix mentions not being deleted efficiently (#15416)
As a regression from the recent optimizations, mentions were left untouched
until `account.destroy`, which would then delete them individually,
and executing queries to find and delete associated notifications, resulting
in a massive slowdown.

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app')
-rw-r--r--app/services/delete_account_service.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb
index 2bb533cfb..f8154cc3e 100644
--- a/app/services/delete_account_service.rb
+++ b/app/services/delete_account_service.rb
@@ -142,6 +142,7 @@ class DeleteAccountService < BaseService
     purge_user!
     purge_profile!
     purge_statuses!
+    purge_mentions!
     purge_media_attachments!
     purge_polls!
     purge_generated_notifications!
@@ -159,6 +160,10 @@ class DeleteAccountService < BaseService
     end
   end
 
+  def purge_mentions!
+    @account.mentions.reorder(nil).where.not(status_id: reported_status_ids).in_batches.delete_all
+  end
+
   def purge_media_attachments!
     @account.media_attachments.reorder(nil).find_each do |media_attachment|
       next if keep_account_record? && reported_status_ids.include?(media_attachment.status_id)