Class: ScheduleWorkers::AutoExtendPackageMainWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- ScheduleWorkers::AutoExtendPackageMainWorker
- Defined in:
- app/workers/schedule_workers/auto_extend_package_main_worker.rb
Instance Method Summary collapse
-
#perform ⇒ Object
Dispatches restaurant processing to sub-workers for parallel execution.
Methods inherited from ApplicationWorker
Instance Method Details
#perform ⇒ Object
Dispatches restaurant processing to sub-workers for parallel execution.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/workers/schedule_workers/auto_extend_package_main_worker.rb', line 17 def perform restaurant_ids = [] Restaurant.with_auto_extend_restaurant_packages.find_each(batch_size: 10) do |restaurant| restaurant_ids << restaurant.id # Use perform_in with random delay (0-5 minutes) to spread the load delay_seconds = rand(0..300) AutoExtendPackageSubWorker.perform_in(delay_seconds, restaurant.id) end BUSINESS_LOGGER.info( "#{self.class}: Dispatched #{restaurant_ids.size} restaurants for package extension processing", restaurant_ids: restaurant_ids, ) end |