Class: MenardInventoryUploadWorker

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

Constant Summary collapse

LOCK_KEY =
'menard_inventory_upload'

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: {})

    Optional overrides

Options Hash (options):

  • 'generate_only' (Boolean)

    Skip the portal upload (just generate spreadsheet)

  • 'triggered_by' (String)

    Who triggered this ('scheduled' or user name)

  • 'catalog_item_ids' (Array<Integer>)

    Present only for the job enqueued by ItemMaintenance
    right after it flips specific rows to +discontinued+. The array is those primary keys only (captured
    immediately before the state update), not a query over “all discontinued.” Usually length 1.
    Spreadsheet = full active + pending_discontinue load, then one row per id (discontinued format) at the end.



18
19
20
21
22
23
24
25
26
# File 'app/workers/menard_inventory_upload_worker.rb', line 18

def perform(options = {})
  result = Catalog.with_advisory_lock_result(LOCK_KEY, timeout_seconds: 0) do
    perform_upload(options.symbolize_keys)
  end

  unless result.lock_was_acquired?
    store info_message: 'Menard inventory upload already in progress — skipped'
  end
end