7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/workers/elasticsearch_reindex_scheduler.rb', line 7
def perform(index_class_name)
index_class = index_class_name.constantize
logger.info "ElasticsearchReindexScheduler #{index_class_name}"
return self.class.perform_in(1.minute, index_class) unless index_class.indexing_allowed? || !index_class.is_heavy_index
starting_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
options = { index_class_name: index_class_name, start_time: starting_time }
reindex_batch = Sidekiq::Batch.new
reindex_batch.on(:success, self.class, options)
reindex_batch.description = "Reindex for #{index_class_name} started at #{DateTime.current.iso8601}"
reindex_batch.jobs do
index_class.reindex
end
::HasUtils::Env.run_on_environment(::HasUtils::Env::TEST) do
if Sidekiq::Testing.inline?
on_success("status", options)
end
end
end
|