Class: CustomerMergeWorker
Instance Attribute Summary
#broadcast_status_updates
Instance Method Summary
collapse
#at, #store, #total
Instance Method Details
8
9
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 8
def perform(options={})
options = options.with_indifferent_access
options = options.deep_symbolize_keys
customer_ids = options[:customer_ids]
notify_email = options[:notify_email]
customer_master = Customer.find(customer_ids.shift)
customer_duplicates = Customer.where(id: customer_ids)
message = "<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, message|
total total_steps
at(current_step, message)
end
store redirect_to: "/customers/#{customer_master.id}"
if report[:customer_errors].any? || report[:execution_errors].any?
InternalMailer.customer_merge_complete(customer_master, user_email: notify_email, report: report).deliver_now
message = '<b>Customer merging failed. A notification email has been sent to you and heatwave team.</b>'
store message: message
end
store message: message
end
|