This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2022-05-18 23:29:14 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Scheduler::IndexingScheduler
|
|
|
|
include Sidekiq::Worker
|
|
|
|
include Redisable
|
|
|
|
|
|
|
|
sidekiq_options retry: 0
|
|
|
|
|
|
|
|
def perform
|
2022-11-05 22:31:52 +01:00
|
|
|
return unless Chewy.enabled?
|
|
|
|
|
2022-05-18 23:29:14 +02:00
|
|
|
indexes.each do |type|
|
|
|
|
with_redis do |redis|
|
|
|
|
ids = redis.smembers("chewy:queue:#{type.name}")
|
|
|
|
|
|
|
|
type.import!(ids)
|
|
|
|
|
|
|
|
redis.pipelined do |pipeline|
|
|
|
|
ids.each { |id| pipeline.srem("chewy:queue:#{type.name}", id) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def indexes
|
|
|
|
[AccountsIndex, TagsIndex, StatusesIndex]
|
|
|
|
end
|
|
|
|
end
|