Sha256: 68c63b4a4a65f30c5b2fff60007b3d0b39475be3b9ab0392316086331d49ffff

Contents?: true

Size: 666 Bytes

Versions: 19

Compression:

Stored size: 666 Bytes

Contents

module Workarea
  class BulkIndexProducts
    include Sidekiq::Worker

    sidekiq_options lock: :until_executing

    class << self
      def perform(ids = Catalog::Product.pluck(:id))
        ids.each_slice(100) do |group|
          perform_by_models(Catalog::Product.in(id: group).to_a)
        end
      end

      def perform_by_models(products)
        return if products.blank?

        documents = Search::ProductEntries.new(products).map(&:as_bulk_document)

        Search::Storefront.bulk(documents)
        products.each { |p| p.set(last_indexed_at: Time.current) }
      end
    end

    def perform(ids)
      self.class.perform(ids)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
workarea-core-3.4.30 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.29 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.28 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.27 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.26 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.25 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.24 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.23 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.22 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.21 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.20 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.19 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.18 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.17 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.16 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.15 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.14 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.13 app/workers/workarea/bulk_index_products.rb
workarea-core-3.4.12 app/workers/workarea/bulk_index_products.rb