Fix to delete StatusCapabilityToken when deleting status batch
This commit is contained in:
parent
e8f7e153e8
commit
28675f7d34
1 changed files with 4 additions and 0 deletions
|
@ -23,6 +23,10 @@ class BatchedRemoveStatusService < BaseService
|
||||||
status.send(:unlink_from_conversations)
|
status.send(:unlink_from_conversations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
status_ids_with_capability_tokens = statuses.local.joins(:capability_tokens).where.not(capability_tokens: { id: nil }).pluck(:id)
|
||||||
|
status_ids_with_capability_tokens += Status.where(reblog_of_id: statuses).local.joins(:capability_tokens).where.not(capability_tokens: { id: nil }).pluck(:id)
|
||||||
|
status_ids_with_capability_tokens.each_slice(50) { |slice| StatusCapabilityToken.where(status_id: slice).delete_all }
|
||||||
|
|
||||||
# We do not batch all deletes into one to avoid having a long-running
|
# We do not batch all deletes into one to avoid having a long-running
|
||||||
# transaction lock the database, but we use the delete method instead
|
# transaction lock the database, but we use the delete method instead
|
||||||
# of destroy to avoid all callbacks. We rely on foreign keys to
|
# of destroy to avoid all callbacks. We rely on foreign keys to
|
||||||
|
|
Loading…
Reference in a new issue