Improve account deletion performances further (#15407)
* Delete status records by batches of 50 * Do not precompute values that are only used once * Do not generate redis events for removal of public toots older than two weeks * Filter reported toots a priori for polls and status deletion * Do not process reblogs when cleaning up public timelines As in Mastodon proper, reblogs don't appear in public TLs * Clean the deleted account's own feed in one go * Refactor Account#clean_feed_manager and List#clean_feed_manager * Delete instead of destroy a few more associations * Fix preloading Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
f18349640b
commit
3249d35bdc
7 changed files with 53 additions and 81 deletions
|
@ -46,10 +46,12 @@ class DeleteAccountService < BaseService
|
|||
featured_tags
|
||||
follow_requests
|
||||
identity_proofs
|
||||
list_accounts
|
||||
migrations
|
||||
mute_relationships
|
||||
muted_by_relationships
|
||||
notifications
|
||||
owned_lists
|
||||
scheduled_statuses
|
||||
status_pins
|
||||
)
|
||||
|
@ -145,15 +147,14 @@ class DeleteAccountService < BaseService
|
|||
purge_media_attachments!
|
||||
purge_polls!
|
||||
purge_generated_notifications!
|
||||
purge_feeds!
|
||||
purge_other_associations!
|
||||
|
||||
@account.destroy unless keep_account_record?
|
||||
end
|
||||
|
||||
def purge_statuses!
|
||||
@account.statuses.reorder(nil).find_in_batches do |statuses|
|
||||
statuses.reject! { |status| reported_status_ids.include?(status.id) } if keep_account_record?
|
||||
|
||||
@account.statuses.reorder(nil).where.not(id: reported_status_ids).in_batches do |statuses|
|
||||
BatchedRemoveStatusService.new.call(statuses, skip_side_effects: skip_side_effects?)
|
||||
end
|
||||
end
|
||||
|
@ -167,11 +168,7 @@ class DeleteAccountService < BaseService
|
|||
end
|
||||
|
||||
def purge_polls!
|
||||
@account.polls.reorder(nil).find_each do |poll|
|
||||
next if keep_account_record? && reported_status_ids.include?(poll.status_id)
|
||||
|
||||
poll.delete
|
||||
end
|
||||
@account.polls.reorder(nil).where.not(status_id: reported_status_ids).in_batches.delete_all
|
||||
end
|
||||
|
||||
def purge_generated_notifications!
|
||||
|
@ -187,6 +184,13 @@ class DeleteAccountService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
def purge_feeds!
|
||||
return unless @account.local?
|
||||
|
||||
FeedManager.instance.clean_feeds!(:home, [@account.id])
|
||||
FeedManager.instance.clean_feeds!(:list, @account.owned_lists.pluck(:id))
|
||||
end
|
||||
|
||||
def purge_profile!
|
||||
# If the account is going to be destroyed
|
||||
# there is no point wasting time updating
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue