Improve performance of deleting OAuth tokens

This commit is contained in:
Claire
2024-02-12 13:29:36 +01:00
parent 56e11650e5
commit d509dda192
3 changed files with 16 additions and 6 deletions

View File

@@ -364,8 +364,11 @@ class User < ApplicationRecord
# Revoke each access token for the Streaming API, since `update_all``
# doesn't trigger ActiveRecord Callbacks:
# TODO: #28793 Combine into a single topic
batch.each do |token|
redis.publish("timeline:access_token:#{token.id}", Oj.dump(event: :kill))
payload = Oj.dump(event: :kill)
redis.pipelined do |pipeline|
batch.ids.each do |id|
pipeline.publish("timeline:access_token:#{id}", payload)
end
end
end
end