Sha256: 292a7bb06e462c23a0608ab2be143c1781297ff80692adfdc7684cecbe91c890
Contents?: true
Size: 817 Bytes
Versions: 10
Compression:
Stored size: 817 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(Workarea.config.bulk_index_batch_size) do |group| perform_by_models(Catalog::Product.in(id: group).to_a) end end def perform_by_models(products) return if products.blank? products = Array.wrap(products) documents = Search::ProductEntries.new(products).map(&:as_bulk_document) Search::Storefront.bulk(documents) Catalog::Product.in(id: products.map(&:id)).set(last_indexed_at: Time.current) end alias_method :perform_by_model, :perform_by_models end def perform(ids) self.class.perform(ids) end end end
Version data entries
10 entries across 10 versions & 1 rubygems