Class: CallDriverWorker

Inherits:
ApplicationWorker show all
Includes:
DeliveryChannel::CourierDriverHelper, ProgressStatus
Defined in:
app/workers/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 included from ProgressStatus

#available_delivery_status, #convert_from_grab_as_symbol, #convert_from_lalamove, #convert_from_lalamove_as_symbol, #convert_from_reservation, #owner_delivery_progress

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#performObject



13
14
15
16
17
18
19
20
21
22
# File 'app/workers/call_driver_worker.rb', line 13

def perform
  Restaurant.distinct.pluck(:time_zone).each do |time_zone|
    restaurants = Restaurant.includes(:delivery_channels).where(activate_auto_call_driver: true).
      where.not(minute_before_delivery_time: nil, call_driver_time_limit_duration: nil).
      where(time_zone: time_zone)
    restaurants.find_each do |restaurant|
      call_driver_for_order_later(restaurant)
    end
  end
end