Class: CustomerMergeWorker
- Inherits:
-
Object
- Object
- CustomerMergeWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/customer_merge_worker.rb
Overview
Sidekiq worker: customer merge.
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/workers/customer_merge_worker.rb', line 10 def perform( = {}) = .deep_symbolize_keys customer_ids = [:customer_ids] notify_email = [:notify_email] customer_master = Customer.find(customer_ids.shift) customer_duplicates = Customer.where(id: customer_ids) = "<b>Customer merged succesfully. #{customer_duplicates.first.reference_number} #{customer_duplicates.first.full_name} has been merged into #{customer_master.reference_number} #{customer_master.full_name} <br>Please note that existing completed quotes retain their original discounts until requoted.</b>" report = Merger::CustomerMerger.batch_merge(customer_master, customer_duplicates) do |current_step, total_steps, | total total_steps at(current_step, ) end store redirect_to: "/customers/#{customer_master.id}" if report[:customer_errors].any? || report[:execution_errors].any? SalesMailer.customer_merge_complete(customer_master, user_email: notify_email, report: report).deliver_now = '<b>Customer merging failed. A notification email has been sent to you and heatwave team.</b>' store message: end store message: end |