]> cat aescling's git repositories - mastodon.git/commitdiff
Improve IP cleanup query (#11871)
authorabcang <abcang1015@gmail.com>
Tue, 17 Sep 2019 06:44:25 +0000 (15:44 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 17 Sep 2019 06:44:25 +0000 (08:44 +0200)
app/workers/scheduler/ip_cleanup_scheduler.rb

index 42620332e7ee8cad0e42ae6622c0d96d1d59159c..4f44078d8e903971dab4be0a4897822dd5be0ef6 100644 (file)
@@ -9,7 +9,7 @@ class Scheduler::IpCleanupScheduler
 
   def perform
     time_ago = RETENTION_PERIOD.ago
-    SessionActivation.where('updated_at < ?', time_ago).destroy_all
-    User.where('last_sign_in_at < ?', time_ago).update_all(last_sign_in_ip: nil)
+    SessionActivation.where('updated_at < ?', time_ago).in_batches.destroy_all
+    User.where('last_sign_in_at < ?', time_ago).where.not(last_sign_in_ip: nil).in_batches.update_all(last_sign_in_ip: nil)
   end
 end