Class: Restaurants::ClearInventoryCacheWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/restaurants/clear_inventory_cache_worker.rb

Overview

Author:

  • Saiqul Haq <saiqulhaq@gmail.com>

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(restaurant_id) ⇒ Object



6
7
8
9
10
11
12
13
# File 'app/workers/restaurants/clear_inventory_cache_worker.rb', line 6

def perform(restaurant_id)
  restaurant = Restaurant.fetch(restaurant_id)
  today = Time.now_in_tz(restaurant.time_zone).to_date
  InventoryReservationWorker.new.perform(restaurant.id, today.to_date, restaurant.expiry_date)

  dates = (today...(restaurant.expiry_date + 1)).to_a
  Restaurant.refresh_inv_checker_by_dates(restaurant.id, dates, self.class.name)
end