Class: CertificationCheckWorker
- Inherits:
-
Object
- Object
- CertificationCheckWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/certification_check_worker.rb
Overview
Sidekiq worker: certification check.
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/workers/certification_check_worker.rb', line 7 def perform # Certification reminder to renew 30 days in advance cer30 = Certification.active.where('expires_at < ? AND expires_at > ?', 30.days.from_now, 10.days.from_now) cer30.each do |certification| certification.send_expiration_reminder_30 unless certification.expiration_reminder_30_days_sent end # Certification reminder to renew 10 days in advance cer10 = Certification.active.where(expires_at: ...10.days.from_now) cer10.each do |certification| certification.send_expiration_reminder_10 unless certification.expiration_reminder_10_days_sent end # Certification reminder to renew when expired cer_expired = Certification.active.where(expires_at: ...Time.current) cer_expired.each(&:expire!) # Course Enrollments reminder to request certificate cour_enr = CourseEnrollment.where(passed_email_sent: true, passed_email_reminder_sent: false) .where('passed_email_sent_at > ?', 10.days.from_now) cour_enr.each(&:send_new_certificate_reminder_email) # Check if there are any active certificates with no liability insurance active. # This might happen in weird cases when AR receives a notification but forgets to check Certification.active.each do |cert| TrainingMailer.certification_without_liability_insurance(cert).deliver_now if cert.customer.liability_insurances.active.blank? end end |