Sha256: 8690855fef339853d1490f8ee996dd2896d5ce7a771fe47f1b395049ca1ddfaf

Contents?: true

Size: 641 Bytes

Versions: 28

Compression:

Stored size: 641 Bytes

Contents

module Workarea
  class KeepProductIndexFresh
    include Sidekiq::Worker

    sidekiq_options(
      lock: :until_executing,
      retry: false,
      query_cache: true
    )

    def perform(*args)
      all = never_indexed + stale
      BulkIndexProducts.perform_by_models(all.take(Workarea.config.stale_products_size))
    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

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.26 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.25 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.23 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.22 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.21 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.20 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.19 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.18 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.17 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.16 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.15 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.14 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.13 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.12 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.11 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.10 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.9 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.8 app/workers/workarea/keep_product_index_fresh.rb
workarea-core-3.5.7 app/workers/workarea/keep_product_index_fresh.rb