Class: CustomerCouponsBoosterWorker

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

Overview

Sidekiq worker: customer coupons booster.

Instance Method Summary collapse

Instance Method Details

#perform(_customer_ids = []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/workers/customer_coupons_booster_worker.rb', line 6

def perform(_customer_ids = [])
  tier2_coupons = Coupon::Tier2ProgramPricing.where(code: %w[PP-SILVER-LEVEL PP-GOLD-LEVEL PP-PLATINUM-LEVEL PP-TITANIUM-LEVEL]).ids
  customers = Customer.joins(:customer_record)
                      .where(tier2_program_pricing_id: tier2_coupons)
                      .where('(customer_records.a12net_rev > ? or customer_records.a12net_rev between ? and ? or customer_records.a12net_rev between ? and ?)',
                              Customer::PricingProgramAssigner::TITANIUM_LEVEL_MIN_THRESHOLD,
                              Customer::PricingProgramAssigner::PLATINUM_LEVEL_MIN_THRESHOLD,
                              Customer::PricingProgramAssigner::PLATINUM_LEVEL_MAX_THRESHOLD,
                              Customer::PricingProgramAssigner::GOLD_LEVEL_MIN_THRESHOLD,
                              Customer::PricingProgramAssigner::GOLD_LEVEL_MAX_THRESHOLD)

  customers.each do |customer|
    Customer::PricingProgramAssigner.new(customer_id: customer.id).coupon_booster
  end
end