mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-30 12:20:35 +00:00
Improve performances of deleting favourites when deleting accounts (#15412)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
62e42bd15b
commit
814b7775fb
|
@ -9,13 +9,11 @@ class DeleteAccountService < BaseService
|
||||||
aliases
|
aliases
|
||||||
block_relationships
|
block_relationships
|
||||||
blocked_by_relationships
|
blocked_by_relationships
|
||||||
bookmarks
|
|
||||||
conversation_mutes
|
conversation_mutes
|
||||||
conversations
|
conversations
|
||||||
custom_filters
|
custom_filters
|
||||||
devices
|
devices
|
||||||
domain_blocks
|
domain_blocks
|
||||||
favourites
|
|
||||||
featured_tags
|
featured_tags
|
||||||
follow_requests
|
follow_requests
|
||||||
identity_proofs
|
identity_proofs
|
||||||
|
@ -147,6 +145,8 @@ class DeleteAccountService < BaseService
|
||||||
purge_media_attachments!
|
purge_media_attachments!
|
||||||
purge_polls!
|
purge_polls!
|
||||||
purge_generated_notifications!
|
purge_generated_notifications!
|
||||||
|
purge_favourites!
|
||||||
|
purge_bookmarks!
|
||||||
purge_feeds!
|
purge_feeds!
|
||||||
purge_other_associations!
|
purge_other_associations!
|
||||||
|
|
||||||
|
@ -178,6 +178,24 @@ class DeleteAccountService < BaseService
|
||||||
Notification.where(from_account: @account).in_batches.delete_all
|
Notification.where(from_account: @account).in_batches.delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def purge_favourites!
|
||||||
|
@account.favourites.in_batches do |favourites|
|
||||||
|
ids = favourites.pluck(:status_id)
|
||||||
|
StatusStat.where(status_id: ids).update_all('favourites_count = GREATEST(0, favourites_count - 1)')
|
||||||
|
Chewy.strategy.current.update(StatusesIndex, ids) if Chewy.enabled?
|
||||||
|
# Rails.cache.delete_multi would be better, but we don't have it yet
|
||||||
|
ids.each { |id| Rails.cache.delete("statuses/#{id}") }
|
||||||
|
favourites.delete_all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def purge_bookmarks!
|
||||||
|
@account.bookmarks.in_batches do |bookmarks|
|
||||||
|
Chewy.strategy.current.update(StatusesIndex, bookmarks.pluck(:status_id)) if Chewy.enabled?
|
||||||
|
bookmarks.delete_all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def purge_other_associations!
|
def purge_other_associations!
|
||||||
associations_for_destruction.each do |association_name|
|
associations_for_destruction.each do |association_name|
|
||||||
purge_association(association_name)
|
purge_association(association_name)
|
||||||
|
|
Loading…
Reference in a new issue