Class: NotificationWorkers::TightTimeCallDriverWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- NotificationWorkers::TightTimeCallDriverWorker
- Includes:
- DeliveryChannel::CourierDriverHelper
- Defined in:
- app/workers/notification_workers/tight_time_call_driver_worker.rb
Overview
typed: ignore frozen_string_literal: true
Instance Method Summary collapse
Methods included from DeliveryChannel::CourierDriverHelper
#can_wait_for_driver, #valid_time_to_call_driver?, #valid_to_call_driver?
Methods inherited from ApplicationWorker
Instance Method Details
#perform(reservation_id) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/workers/notification_workers/tight_time_call_driver_worker.rb', line 9 def perform(reservation_id) reservation = Reservation.find(reservation_id) return false unless valid_to_call_driver?(reservation) restaurant = reservation.restaurant now = Time.now_in_tz(restaurant.time_zone) setting_time = restaurant.minute_before_delivery_time.to_i.minutes + waiting_time(restaurant) call_time = reservation.reservation_time - setting_time tight_time = call_time < now && now < reservation.reservation_time send_staff_notification(reservation) if tight_time end |
#send_staff_notification(reservation) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'app/workers/notification_workers/tight_time_call_driver_worker.rb', line 23 def send_staff_notification(reservation) restaurant = reservation.restaurant subject = "Tight time to call driver, Booking ID #{reservation.id}" body = "Tight time to call driver. Booking ID #{reservation.id}. #{reservation.date} at #{reservation.start_time_format}. #{restaurant.name_en} (#{restaurant.id})" StaffMailer.notify_cancel_auto_call_driver_staff(subject, body).deliver_later! msg = "Tight time to call driver. Booking ID #{reservation.id}. #{reservation.date} at #{reservation.start_time_format}. #{restaurant.short_name_sms} (#{restaurant.id})" phones = AdminSetting.phone_receiver_when_failed_order_driver SmsWorker.new.perform(msg, phones, reservation.id) end |