Class: GenerateQuoteWorker
- Inherits:
-
Object
- Object
- GenerateQuoteWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/generate_quote_worker.rb
Overview
Sidekiq worker: generate quote.
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 43 44 45 46 |
# File 'app/workers/generate_quote_worker.rb', line 10 def perform( = {}) = .deep_symbolize_keys quote = Quote.find([:quote_id]) = [:quote_options] || {} quote.room_configurations.reject(&:quoted_heating_system_pl_id).each(&:set_quoted_heating_system_product_line) quote_upload_category = [:preview].to_b ? 'preview_organization_quote_pdf' : 'organization_quote_pdf' quote_upload_category = 'materials_pdf' if .dig(:materials_only).to_b combined_pdf_result = Quote::CombinedPdfGenerator.new.process(quote, ) do |current_step, total_steps, | total total_steps at(current_step, ) end if [:preview].to_b upload = Upload.uploadify(combined_pdf_result.pdf_file_path, quote_upload_category) store upload_id: upload.id else new_uploads = [] upload = Upload.uploadify(combined_pdf_result.pdf_file_path, quote_upload_category, quote, combined_pdf_result.file_name) quote.uploads << upload new_uploads << upload if combined_pdf_result.copy_of_plans_pdf_file_path plans_upload = Upload.uploadify(combined_pdf_result.copy_of_plans_pdf_file_path, 'copy_of_plans_pdf', quote, combined_pdf_result.copy_of_plans_file_name) quote.uploads << plans_upload new_uploads << plans_upload end combined_pdf_result..each do |upload_id| new_uploads << Upload.find(upload_id) end store redirect_to: "/quotes/#{quote.id}/build_communication?#{new_uploads.map { |u| "upload_ids[]=#{u.id}" }.join('&')}" end end |