Class: ScheduleWorkers::AutoExtendAddOnSubWorker

Inherits:
ApplicationWorker show all
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

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(restaurant_id) ⇒ void

This method returns an undefined value.

Processes a single restaurant's auto-extend add-ons.

Parameters:

  • restaurant_id (Integer)

    The restaurant ID to process



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