Class: SmartServicesNotificationWorker
- Inherits:
-
Object
- Object
- SmartServicesNotificationWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/smart_services_notification_worker.rb
Overview
Sidekiq worker: smart services notification.
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 |
# File 'app/workers/smart_services_notification_worker.rb', line 7 def perform SupportCase.services.where(service_date: Time.current, service_time: Time.current..2.hours.from_now).find_each do |sc| return if sc.notified_at.present? msg = "SmartService scheduled in the next 2 hours. Case #{sc.case_number}. " msg += if sc.service_address_id.present? "Service provided in #{sc.service_address.city}, #{sc.service_address.state_code}." else "Service address unknown" end # SMS sent to JL's phone number TwilioClient.(to: sc.field_technician_cell, body: msg) sc.update(notified_at: Time.current) end SupportCase.services.where(service_date: 1.working.day.from_now).find_each do |sc| return if sc.customer_24h_notification.present? sc.send_24h_customer_notification end end |