Use touch_all with batches (#32799)
				
					
				
			This commit is contained in:
		@@ -32,7 +32,7 @@ module Admin
 | 
			
		||||
 | 
			
		||||
    def deactivate_all
 | 
			
		||||
      authorize :invite, :deactivate_all?
 | 
			
		||||
      Invite.available.in_batches.update_all(expires_at: Time.now.utc)
 | 
			
		||||
      Invite.available.in_batches.touch_all(:expires_at)
 | 
			
		||||
      redirect_to admin_invites_path
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -340,7 +340,7 @@ class User < ApplicationRecord
 | 
			
		||||
    Doorkeeper::AccessGrant.by_resource_owner(self).update_all(revoked_at: Time.now.utc)
 | 
			
		||||
 | 
			
		||||
    Doorkeeper::AccessToken.by_resource_owner(self).in_batches do |batch|
 | 
			
		||||
      batch.update_all(revoked_at: Time.now.utc)
 | 
			
		||||
      batch.touch_all(:revoked_at)
 | 
			
		||||
      Web::PushSubscription.where(access_token_id: batch).delete_all
 | 
			
		||||
 | 
			
		||||
      # Revoke each access token for the Streaming API, since `update_all``
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ class UnallowDomainService < BaseService
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def suspend_accounts!(domain)
 | 
			
		||||
    Account.where(domain: domain).in_batches.update_all(suspended_at: Time.now.utc)
 | 
			
		||||
    Account.where(domain: domain).in_batches.touch_all(:suspended_at)
 | 
			
		||||
    AfterUnallowDomainWorker.perform_async(domain)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user