Class: AmazonCatalogItemListingsDataWorker
- Inherits:
-
Object
- Object
- AmazonCatalogItemListingsDataWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/amazon_catalog_item_listings_data_worker.rb
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
-
#perform(options = {}) ⇒ Object
Pulls and populated Amazon Seller API listings items data for Amazon Seller Central US (76) and Canada (77) catalog items.
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(options = {}) ⇒ Object
Pulls and populated Amazon Seller API listings items data for Amazon Seller Central US (76) and Canada (77) catalog items
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 |
# File 'app/workers/amazon_catalog_item_listings_data_worker.rb', line 17 def perform( = {}) = .symbolize_keys [:catalog_ids] = [CatalogConstants::AMAZON_SC_US_CATALOG_ID, CatalogConstants::AMAZON_SC_CA_CATALOG_ID] unless [:catalog_ids].present? [:refresh_if_older_than] = 1.days.ago logger.debug("AmazonCatalogItemListingsDataWorker starting") start_time = Time.current result = Catalog::PullAmazonCatalogsListingsData.new.process() do |status| total status[:total] at status[:at], status[:message] # Log progress every 50 items if status[:at] % 50 == 0 elapsed = Time.current - start_time rate = status[:at] / elapsed * 60 # items per minute logger.info "Progress: #{status[:at]}/#{status[:total]} items (#{rate.round(1)}/min)" end end elapsed = Time.current - start_time logger.info "AmazonCatalogItemListingsDataWorker completed in #{elapsed.round(0)}s: #{result.catalog_items_updated.size} updated, #{result.catalog_items_failed.size} failed" store redirect_to: [:redirect_to] end |