Class: AmazonPricingAutomationWorker

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

Overview

Sidekiq worker: amazon pricing automation.

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

Runs pricing automation for Amazon Seller Central US (76) and Canada (77).

EU is deliberately NOT here yet, though AmazonCatalogItemListingsDataWorker
now collects its offer data. Every one of the ~259 EU listings carries
auto_buy_box because that is the column default, not because anyone chose
it, and their is_amz_buy_box_winner / is_amz_featured_merchant flags are
still the stale false they were created with. Enabling repricing in the
same change that starts populating those flags would put 259 prices under
automation the moment real data landed, on rules nobody set. Extend
CatalogConstants::AMAZON_SELLER_IDS here once the pulled data has been
reviewed and per-item rules are deliberate.

Parameters:

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

    job options

Options Hash (options):

  • catalog_ids (Array<Integer>)

    catalog IDs to reprice (defaults to Seller Central US and Canada)

  • redirect_to (String)

    path to redirect to when the job completes



24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/amazon_pricing_automation_worker.rb', line 24

def perform(options = {})
  options[:catalog_ids] = [CatalogConstants::AMAZON_SC_US_CATALOG_ID, CatalogConstants::AMAZON_SC_CA_CATALOG_ID] if options[:catalog_ids].blank?

  result = Catalog::AmazonPricingAutomationService.new.process(options) do |status|
    at 0, "Processing catalog item #{status[:catalog_item].id} (#{status[:catalog_item].sku})" if status[:catalog_item]
  end

  logger.info "Amazon Pricing Automation completed: #{result.processed_count} processed, #{result.price_increased_count} prices increased, #{result.price_lowered_count} prices lowered, #{result.flagged_count} flagged"

  store redirect_to: options[:redirect_to]
end