Class: GenerateExportedCatalogPacketWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job, Workers::StatusBroadcastable
Defined in:
app/workers/generate_exported_catalog_packet_worker.rb

Overview

Sidekiq worker: generate exported catalog packet.

Instance Attribute Summary

Attributes included from Workers::StatusBroadcastable

#broadcast_status_updates

Instance Method Summary collapse

Methods included from Workers::StatusBroadcastable::Overrides

#at, #store, #total

Instance Method Details

#perform(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    job options

Options Hash (options):

  • packet_id (Integer)
  • export_csv (Boolean)

    include a CSV export in the packet

  • export_xlsx (Boolean)

    include an XLSX export in the packet

  • export_images (Boolean)

    include product images in the packet

  • export_literatures (Boolean)

    include literature documents in the packet

  • return_path (String)

    path to redirect to when the job completes



15
16
17
18
19
20
21
22
23
# File 'app/workers/generate_exported_catalog_packet_worker.rb', line 15

def perform(options = {})
  packet = ExportedCatalogItemPacket.find(options[:packet_id])
  upload = packet.generate_packet(export_csv: options[:export_csv], export_xlsx: options[:export_xlsx],
                                  export_images: options[:export_images],
                                  export_literatures: options[:export_literatures])
  store upload_id: upload.id
  store redirect_to: options[:return_path]
  store complete_message: 'Packet generated succesfully'
end