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