Class: ScheduleWorkers::OccupancyRestaurantExportWorker

Inherits:
ApplicationWorker show all
Includes:
ElasticAPM::SpanHelpers
Defined in:
app/workers/schedule_workers/occupancy_restaurant_export_worker.rb

Overview

This worker handles exporting occupancy data for a specific restaurant It is spawned by OccupancyExportWorker to run in parallel for each restaurant

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(restaurant_id, timestamp = nil) ⇒ Object



11
12
13
14
15
16
17
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
# File 'app/workers/schedule_workers/occupancy_restaurant_export_worker.rb', line 11

def perform(restaurant_id, timestamp = nil)
  timestamp ||= Time.current.to_i

  BUSINESS_LOGGER.info('Starting restaurant occupancy export', {
                         restaurant_id: restaurant_id,
                         timestamp: timestamp,
                       })

  begin
    export_restaurant_occupancy_data(restaurant_id, timestamp)

    BUSINESS_LOGGER.info('Restaurant occupancy export completed successfully', {
                           restaurant_id: restaurant_id,
                           timestamp: timestamp,
                           s3_path: s3_file_path(restaurant_id, timestamp),
                         })
  rescue StandardError => e
    APMErrorHandler.report(e, context: {
                             job_class: self.class.name,
                             restaurant_id: restaurant_id,
                             timestamp: timestamp,
                           })

    BUSINESS_LOGGER.error('Restaurant occupancy export failed', {
                            restaurant_id: restaurant_id,
                            error: e.message,
                            backtrace: e.backtrace.first(5),
                            timestamp: timestamp,
                          })

    raise e
  end
end