Class: ScheduleWorkers::AutoExtendAddOnSubWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- ScheduleWorkers::AutoExtendAddOnSubWorker
- Defined in:
- app/workers/schedule_workers/auto_extend_add_on_sub_worker.rb
Overview
AutoExtendAddOnSubWorker processes individual restaurants to extend add-on end dates. This worker handles the actual business logic for a single restaurant.
Instance Method Summary collapse
-
#perform(restaurant_id) ⇒ void
Processes a single restaurant's auto-extend add-ons.
Methods inherited from ApplicationWorker
Instance Method Details
#perform(restaurant_id) ⇒ void
This method returns an undefined value.
Processes a single restaurant's auto-extend add-ons.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/workers/schedule_workers/auto_extend_add_on_sub_worker.rb', line 18 def perform(restaurant_id) restaurant = find_restaurant(restaurant_id) return unless restaurant # Skip if restaurant is not active and not bookable if !restaurant.active && !restaurant.allow_booking BUSINESS_LOGGER.info( "#{self.class}: Skipping restaurant #{restaurant.id} - inactive and not bookable", restaurant_id: restaurant.id, active: restaurant.active, allow_booking: restaurant.allow_booking, ) return end return unless restaurant.bookable_and_not_expired? updated = update_restaurant_and_add_ons(restaurant) if updated BUSINESS_LOGGER.info( "#{self.class}: Updated add-ons expiry dates for restaurant: #{restaurant.id}", ) end rescue ActiveRecord::RecordNotFound BUSINESS_LOGGER.warn( "#{self.class}: Restaurant #{restaurant_id} not found, skipping", ) rescue StandardError => e APMErrorHandler.report(e, context: { restaurant_id: restaurant_id }) raise e end |