This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-09-14 13:26:38 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Scheduler::IpCleanupScheduler
|
|
|
|
include Sidekiq::Worker
|
|
|
|
|
2018-04-04 12:47:39 -07:00
|
|
|
RETENTION_PERIOD = 1.year
|
|
|
|
|
2020-03-31 12:59:03 -07:00
|
|
|
sidekiq_options lock: :until_executed, retry: 0
|
2018-08-19 06:48:29 -07:00
|
|
|
|
2017-09-14 13:26:38 -07:00
|
|
|
def perform
|
2018-04-04 12:47:39 -07:00
|
|
|
time_ago = RETENTION_PERIOD.ago
|
2019-09-16 23:44:25 -07:00
|
|
|
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)
|
2017-09-14 13:26:38 -07:00
|
|
|
end
|
|
|
|
end
|