Class: RequoteWorker
- Inherits:
-
Object
- Object
- RequoteWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/requote_worker.rb
Overview
Sidekiq worker: requote.
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 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/workers/requote_worker.rb', line 10 def perform( = {}) quote_id = [:quote_id] rma_id = [:rma_id] redirect_path = [:redirect_path] || "/quotes/#{quote_id}" total 3 at(1, 'Loading quote...') quote = Quote.find(quote_id) at(2, 'Creating revised quote...') reviser = Quote::Reviser.new(quote, rma_id: rma_id) new_quote = reviser.revise errors = reviser.errors at(3, 'Finalizing...') if errors.empty? store redirect_to: "/quotes/#{new_quote.id}/rooms" store message: 'Quote revised successfully.' else store redirect_to: redirect_path store message: "Could not requote: #{errors.join(', ')}" store error_message: "Could not requote: #{errors.join(', ')}" end rescue StandardError => e store message: "Error requoting: #{e.}" store error_message: "Failed to requote: #{e.}" store redirect_to: redirect_path Rails.logger.error("RequoteWorker error for quote #{quote_id}: #{e.}\n#{e.backtrace.join("\n")}") raise # AppSignal catches this automatically end |