Class: StandaloneLabelWorker
- Inherits:
-
Object
- Object
- StandaloneLabelWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/standalone_label_worker.rb
Overview
Generates standalone-delivery ship labels in the background, with live
progress on the CRM job page ("working in the background…").
Exists for Spee-Dee (Dispatch Science): its carrier-side barcode job can take
30s+ in production, which blew past the web request budget when
StandaloneDelivery#generate_labels ran inline (504s + orphaned DS orders,
2026-07-28). Sidekiq has no such clock, so the poll gets the client's full
2-minute window here. Other carriers keep the fast inline path in
StandaloneDeliveriesController#create_ship_labels.
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(options = {}) ⇒ void
This method returns an undefined value.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/workers/standalone_label_worker.rb', line 23 def perform( = {}) = .deep_symbolize_keys standalone_delivery = StandaloneDelivery.find_by(id: [:standalone_delivery_id]) return unless standalone_delivery total 2 at(1, 'Creating the Spee-Dee order and waiting for its barcodes…') result = standalone_delivery.generate_labels if result[:status_code] == :ok && standalone_delivery.all_labels_pdf at(2, 'Labels ready — printing…') standalone_delivery.ship_label_standalone_delivery! # upload_id gives the job page a download button AND auto-opens the # combined label PDF when the operator follows the redirect. store upload_id: standalone_delivery.all_labels_pdf.id store redirect_to: "/standalone_deliveries/#{standalone_delivery.id}", info_message: "#{standalone_delivery.name} generated ship label(s)." else store redirect_to: "/standalone_deliveries/#{standalone_delivery.id}", error_message: "Unable to print all ship label(s), please void if necessary, result: #{result[:status_message]}" end end |