Skip to content

Commit 52c889a

Browse files
abcanghiyuki2578
authored andcommitted
Improve IP cleanup query (mastodon#11871)
1 parent dc31e5c commit 52c889a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/workers/scheduler/ip_cleanup_scheduler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Scheduler::IpCleanupScheduler
99

1010
def perform
1111
time_ago = RETENTION_PERIOD.ago
12-
SessionActivation.where('updated_at < ?', time_ago).destroy_all
13-
User.where('last_sign_in_at < ?', time_ago).update_all(last_sign_in_ip: nil)
12+
SessionActivation.where('updated_at < ?', time_ago).in_batches.destroy_all
13+
User.where('last_sign_in_at < ?', time_ago).where.not(last_sign_in_ip: nil).in_batches.update_all(last_sign_in_ip: nil)
1414
end
1515
end

0 commit comments

Comments
 (0)