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
-
#perform ⇒ Object
Runs the job.
Instance Method Details
#perform ⇒ Object
Runs the job.
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 35 36 |
# File 'app/workers/certification_check_worker.rb', line 10 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) # Escalate certified installers whose liability insurance has lapsed: remind # the customer (with a deadline), then suspend the certification if it is never # renewed. Replaces the former per-run rep alert. Certification::InsuranceEscalation.new.call end |