Class: Vendors::SevenRooms::RestaurantsInventorySyncSchedulerWorker

Inherits:
ApplicationWorker
  • Object
show all
Defined in:
app/workers/vendors/seven_rooms/restaurants_inventory_sync_scheduler_worker.rb

Overview

This worker schedules inventory synchronization for sevenrooms restaurants by delegating all business logic to VendorsService::InventorySync::SchedulerService.

The worker serves as a thin wrapper that:

  • Handles Sidekiq job lifecycle (retry, queue management)

  • Delegates all business logic to the service layer

  • Returns boolean result based on service execution

The underlying service supports different sync strategies:

  • :four_days - Full sync of all available inventory days (up to restaurant.days_in_advance)

  • :one_day - Partial sync of up to 28 days

  • :four_hours - Quick sync of just 7 days ahead

The worker can be triggered:

  • On a schedule (typically runs daily at 5pm Bangkok time)

  • Manually for specific restaurants (force update from admin dashboard)

Note: sevenrooms has stricter rate limits (1000 requests/10 seconds) compared to other suppliers, so batch processing uses smaller batch sizes and shorter delay intervals.

Instance Method Summary collapse

Instance Method Details

#perform(restaurant_ids = nil, trigger_type = nil) ⇒ Boolean

Schedules inventory sync for sevenrooms restaurants by delegating to the service

Parameters:

  • restaurant_ids (Array<Integer>, nil) (defaults to: nil)

    Optional list of restaurant IDs to sync; nil for all

  • trigger_type (String, nil) (defaults to: nil)

    Type of sync to perform (four_days, one_day, four_hours)

Returns:

  • (Boolean)

    true if service executed successfully, false otherwise



31
32
33
34
# File 'app/workers/vendors/seven_rooms/restaurants_inventory_sync_scheduler_worker.rb', line 31

def perform(restaurant_ids = nil, trigger_type = nil)
  service = VendorsService::InventorySync::SchedulerService.new(supplier: :sevenrooms)
  service.schedule_sync(restaurant_ids: restaurant_ids, trigger_type: trigger_type&.to_sym)
end