Sha256: f3d072fad0b54b566509e108efe1f8cd91416e35771a3b43cdfa1c5986e78544
Contents?: true
Size: 681 Bytes
Versions: 4
Compression:
Stored size: 681 Bytes
Contents
module Workarea class RestockNotifier include Sidekiq::Worker include Sidekiq::CallbacksWorker sidekiq_options( enqueue_on: { Inventory::Sku => :save }, queue: 'low', retry: false ) def perform(id) sku = Inventory::Sku.find(id) return unless sku.purchasable? InventoryNotification.unsent.where(sku: sku.id).each do |notification| send_notification(notification); end end def send_notification(notification) attrs = notification.attributes.values_at('product_id', 'sku', 'email') notification.mark_as_sent! if Storefront::InventoryUpdateMailer.notify(*attrs).deliver end end end
Version data entries
4 entries across 4 versions & 1 rubygems