class OrderQueueProcessorJob < ApplicationJob
  queue_as :default

  def perform(order_id, table_id)
    # Do something later
    #Order ID     
    order = Order.find(order_id)    

    #Execute orders and send to order stations
    if order
      oqs = OrderQueueStation.new
      oqs.process_order(order, table_id)
    end

    assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
    ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
  end

  # private 

  # def render_order(assign_order) 
  #   ApplicationController.renderer.render(partial: 'oqs/oqs_test', 
  #     locals: { order: assign_order}) 
  # end
# Read more at https://www.pluralsight.com/guides/ruby-ruby-on-rails/creating-a-chat-using-rails-action-cable#TehYiuqlHDOXaQQk.99

end
