10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/workers/good_job/elasticsearch_process_change_logs_worker.rb', line 10
def perform(klass_name)
return if klass_name.blank?
return unless defined?(::ChangeLog)
klass = klass_name.constantize
start_time = Time.current
index_klass = constantize_index_class(klass)
build_query(klass).find_each(batch_size: BATCH_SIZE) do |change_log|
break if exceeded_max_processing_time?(start_time)
define_inheritance_search(klass) if index_klass
instance = klass.find_by(id: change_log.record_id)
next unless instance
process_dependencies_for(instance, change_log, klass) if has_dependencies?(change_log)
reindex_record(index_klass, instance, change_log.id) if index_klass
end
end
|