Class: CatalogPriceChangesAlertWorker
- Inherits:
-
Object
- Object
- CatalogPriceChangesAlertWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/catalog_price_changes_alert_worker.rb
Overview
Sidekiq worker: catalog price changes alert.
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/workers/catalog_price_changes_alert_worker.rb', line 9 def perform # Detailed line-by-line alerts for the main WarmlyYours catalogs only. # Amazon Seller Central is intentionally excluded here — its price moves # are reported separately in the Amazon Repricing Report (buy box vs. # competitive external pricing), so including it here is redundant. @main_catalogs = ViewProductCatalog.where(price_updated_at: 1.day.ago.all_day) .where(catalog_id: Catalog.main_catalog_ids) .where.not(old_price: nil) .order(:item_id, :catalog_id) .select(:catalog_item_id, :item_sku, :catalog_id, :catalog_name, :currency_symbol, :price, :old_price, :sale_price, :price_updated_at) # Summary counts for all other catalogs. Excludes the main WarmlyYours # catalogs shown in detail above and the Amazon Seller Central catalogs # (reported separately), so Amazon stays out of this email entirely. @other_catalogs = ViewProductCatalog.where(price_updated_at: 1.day.ago.all_day) .where.not(catalog_id: Catalog.price_alert_catalog_ids) .where.not(old_price: nil) .order('3 desc') .select('catalog_id, catalog_name, count(id) as num_items') .group(:catalog_id, :catalog_name) InventoryMailer.catalog_price_changes_alert(@main_catalogs, @other_catalogs).deliver_now if Date.yesterday.wday != 0 && Date.yesterday.wday != 6 && (@main_catalogs.present? || @other_catalogs.present?) end |