about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authoralpaca-tc <alpaca-tc@alpaca.tc>2017-05-07 00:03:34 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-06 17:03:34 +0200
commita0b19517915f6c6ae839b036ba466aacd46a9485 (patch)
tree6d8a666d6cc4a034ebc199fd617ad4e6499c1bad /app/services
parent2d45794956d3a3041b041c857891202933ea39f7 (diff)
Refactor domain_blocks_controller (#2843)
* Set domain_block by before_action

* Cast value with ActiveRecord::Type

* Batch update
Diffstat (limited to 'app/services')
-rw-r--r--app/services/block_domain_service.rb2
-rw-r--r--app/services/unblock_domain_service.rb6
2 files changed, 5 insertions, 3 deletions
diff --git a/app/services/block_domain_service.rb b/app/services/block_domain_service.rb
index d15a1e83c..3f8f5b385 100644
--- a/app/services/block_domain_service.rb
+++ b/app/services/block_domain_service.rb
@@ -19,7 +19,7 @@ class BlockDomainService < BaseService
   end
 
   def silence_accounts!
-    blocked_domain_accounts.update_all(silenced: true)
+    blocked_domain_accounts.in_batches.update_all(silenced: true)
     clear_media! if domain_block.reject_media?
   end
 
diff --git a/app/services/unblock_domain_service.rb b/app/services/unblock_domain_service.rb
index 9794e439d..77460f76b 100644
--- a/app/services/unblock_domain_service.rb
+++ b/app/services/unblock_domain_service.rb
@@ -3,10 +3,12 @@
 class UnblockDomainService < BaseService
   def call(domain_block, retroactive)
     if retroactive
+      accounts = Account.where(domain: domain_block.domain).in_batches
+
       if domain_block.silence?
-        Account.where(domain: domain_block.domain).update_all(silenced: false)
+        accounts.update_all(silenced: false)
       else
-        Account.where(domain: domain_block.domain).update_all(suspended: false)
+        accounts.update_all(suspended: false)
       end
     end