6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/workers/smart_services_notification_worker.rb', line 6
def perform
SupportCase.services.where(service_date: Time.current, service_time: Time.current..Time.current + 2.hours).each do |sc|
return if sc.notified_at.present?
msg = "SmartService scheduled in the next 2 hours. Case #{sc.case_number}. "
if sc.service_address_id.present?
msg += "Service provided in #{sc.service_address.city}, #{sc.service_address.state_code}."
else
msg += "Service address unknown"
end
TwilioClient.send_message(to: sc.field_technician_cell,
body: msg)
sc.update(notified_at: Time.current)
end
SupportCase.services.where(service_date: 1.working.day.from_now).each do |sc|
return if sc.customer_24h_notification.present?
sc.send_24h_customer_notification
end
end
|