Class: Workarea::SaveOrderCancellationMetrics

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker, SaveMetrics
Defined in:
app/workers/workarea/save_order_cancellation_metrics.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.perform(order, cancel_data = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/workers/workarea/save_order_cancellation_metrics.rb', line 7

def perform(order, cancel_data = {})
  metrics = OrderCancellationMetrics.new(
    order,
    **cancel_data.symbolize_keys
  )

  save_sales(metrics)
  save_user(metrics)
  save_products(metrics)
  save_skus(metrics)
  save_country(metrics)
  save_segments(metrics)

  order.metrics_saved!
end

.save_user(metrics) ⇒ Object



23
24
25
26
27
28
# File 'app/workers/workarea/save_order_cancellation_metrics.rb', line 23

def save_user(metrics)
  Metrics::User.save_cancellation(
    at: metrics.occured_at,
    **metrics.user_data
  )
end

Instance Method Details

#perform(order_id, cancel_data = {}) ⇒ Object



31
32
33
# File 'app/workers/workarea/save_order_cancellation_metrics.rb', line 31

def perform(order_id, cancel_data = {})
  self.class.perform(Order.find(order_id), cancel_data)
end