mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 15:06:23 +02:00
added mail contronller and job for notificate registrars and admins about accreditation expire date
This commit is contained in:
parent
c5719a35f1
commit
e74cf2bc7f
7 changed files with 78 additions and 4 deletions
29
app/jobs/notify_accreditation_admins_and_registrars_job.rb
Normal file
29
app/jobs/notify_accreditation_admins_and_registrars_job.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
class NotifyAccreditationAdminsAndRegistrarsJob < ApplicationJob
|
||||
MONTH_BEFORE = 5.minute.freeze
|
||||
|
||||
def perform
|
||||
prepare_data_month_before.each do |user|
|
||||
next if user.registrar.email.nil?
|
||||
|
||||
AccreditationCenterMailer.test_results_will_expired_in_one_month(user.registrar.email).deliver_now
|
||||
end
|
||||
|
||||
prepare_data_expired_data.each do |user|
|
||||
next if user.registrar.email.nil?
|
||||
|
||||
AccreditationCenterMailer.test_results_are_expired(user.registrar.email).deliver_now
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def prepare_data_month_before
|
||||
ApiUser.where("accreditation_expire_date > ? AND accreditation_expire_date < ?",
|
||||
Time.now.beginning_of_day + MONTH_BEFORE,
|
||||
Time.now.end_of_day + MONTH_BEFORE).includes(:registrar)
|
||||
end
|
||||
|
||||
def prepare_data_expired_data
|
||||
ApiUser.where("accreditation_expire_date < ?", Time.now.beginning_of_day).includes(:registrar)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue