Class: CatalogItemSaleWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/catalog_item_sale_worker.rb

Instance Method Summary collapse

Instance Method Details

#performObject

Removes the sale price attribute if the sale has already expired



9
10
11
12
13
14
15
16
17
# File 'app/workers/catalog_item_sale_worker.rb', line 9

def perform
  cis_with_sale = CatalogItem.where.not(sale_price_expiration_date: nil)
  cis_with_sale.each do |ci|
    if ci.sale_price_expiration_date < Time.now
      ci.update_columns(sale_price: nil, sale_price_effective_date: nil, sale_price_expiration_date: nil)
    end
  end

end