Sha256: f254695ba65423dd8625c2cba7e86df4bb95d4bdeaf7a27ed9f00332ec7d3d48

Contents?: true

Size: 646 Bytes

Versions: 34

Compression:

Stored size: 646 Bytes

Contents

module Workarea
  class KeepProductIndexFresh
    include Sidekiq::Worker

    sidekiq_options(
      lock: :until_executing,
      retry: false
    )

    def perform(*args)
      all = never_indexed + stale

      all.take(Workarea.config.stale_products_size).each do |product|
        IndexProduct.perform(product)
      end
    end

    def never_indexed
      Catalog::Product
        .where(last_indexed_at: nil)
        .limit(Workarea.config.stale_products_size)
        .to_a
    end

    def stale
      Catalog::Product
        .asc(:last_indexed_at)
        .limit(Workarea.config.stale_products_size)
        .to_a
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.44 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.43 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.42 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.41 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.40 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.39 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.38 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.37 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.36 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.35 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.34 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.33 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.32 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.31 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.30 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.29 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.28 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.27 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.4.26 app/workers/workarea/keep_product_index_fresh.rb