2020-09-01 01:50:02 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Scheduler::ExpiringProScheduler
|
|
|
|
include Sidekiq::Worker
|
|
|
|
|
2020-10-16 22:25:58 +01:00
|
|
|
sidekiq_options queue: 'mailers', retry: 12
|
2020-09-19 04:49:34 +01:00
|
|
|
|
2020-09-01 01:50:02 +01:00
|
|
|
def perform
|
|
|
|
expired_accounts.find_each do |acct|
|
|
|
|
ExpireAccountProWorker.perform_async(acct.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def expired_accounts
|
2020-09-19 04:49:34 +01:00
|
|
|
Account.where('is_pro=TRUE AND pro_expires_at BETWEEN ? AND ?', 1.day.ago, Time.now.utc)
|
2020-09-01 01:50:02 +01:00
|
|
|
end
|
2020-09-19 04:49:34 +01:00
|
|
|
end
|