Added emails for reminding past PRO members to upgrade again
• Added: - emails for reminding past PRO members to upgrade again
This commit is contained in:
21
app/workers/remind_expired_account_pro_worker.rb
Normal file
21
app/workers/remind_expired_account_pro_worker.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemindExpiredAccountProWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'mailers', retry: 2
|
||||
|
||||
attr_reader :user
|
||||
|
||||
def perform(acct_id, date_range)
|
||||
@acct = Account.find(acct_id)
|
||||
deliver_email(date_range)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deliver_email(date_range)
|
||||
UserMailer.remind_expired_pro(@acct.user, date_range).deliver_now!
|
||||
@acct.user.touch(:last_emailed_at)
|
||||
end
|
||||
end
|
||||
45
app/workers/scheduler/remind_expired_pro_scheduler.rb
Normal file
45
app/workers/scheduler/remind_expired_pro_scheduler.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::RemindExpiredProScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 1
|
||||
|
||||
def perform
|
||||
expired_accounts(8.days.ago, 7.days.ago).find_each do |acct|
|
||||
RemindExpiredAccountProWorker.perform_async(acct.id, '7')
|
||||
end
|
||||
|
||||
expired_accounts(17.days.ago, 16.days.ago).find_each do |acct|
|
||||
RemindExpiredAccountProWorker.perform_async(acct.id, '16')
|
||||
end
|
||||
|
||||
expired_accounts(31.days.ago, 30.days.ago).find_each do |acct|
|
||||
RemindExpiredAccountProWorker.perform_async(acct.id, '30')
|
||||
end
|
||||
|
||||
expired_accounts(46.days.ago, 45.days.ago).find_each do |acct|
|
||||
RemindExpiredAccountProWorker.perform_async(acct.id, '45')
|
||||
end
|
||||
|
||||
expired_accounts(61.days.ago, 60.days.ago).find_each do |acct|
|
||||
RemindExpiredAccountProWorker.perform_async(acct.id, '60')
|
||||
end
|
||||
|
||||
expired_accounts(76.days.ago, 75.days.ago).find_each do |acct|
|
||||
RemindExpiredAccountProWorker.perform_async(acct.id, '75')
|
||||
end
|
||||
|
||||
expired_accounts(91.days.ago, 90.days.ago).find_each do |acct|
|
||||
RemindExpiredAccountProWorker.perform_async(acct.id, '90')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def expired_accounts(start_date, end_date)
|
||||
Account.where('is_pro=FALSE AND pro_expires_at BETWEEN ? AND ?', start_date, end_date)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user