Fixes #3562 - Add console output for searchindex rebuild status.
This commit is contained in:
parent
41efbf41f5
commit
8d01fdd7cc
1 changed files with 16 additions and 13 deletions
|
@ -187,7 +187,7 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
# methods defined here are going to extend the class, not the instance of it
|
# methods defined here are going to extend the class, not the instance of it
|
||||||
class_methods do
|
class_methods do # rubocop:disable Metrics/BlockLength
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
|
@ -215,20 +215,23 @@ reload search index with full data
|
||||||
def search_index_reload
|
def search_index_reload
|
||||||
tolerance = 10
|
tolerance = 10
|
||||||
tolerance_count = 0
|
tolerance_count = 0
|
||||||
ids = all.order(created_at: :desc).pluck(:id)
|
batch_size = 100
|
||||||
ids.each do |item_id|
|
query = all.order(created_at: :desc)
|
||||||
item = find_by(id: item_id)
|
total = query.count
|
||||||
next if !item
|
query.find_in_batches(batch_size: batch_size).with_index do |group, batch|
|
||||||
next if item.ignore_search_indexing?(:destroy)
|
group.each do |item|
|
||||||
|
next if item.ignore_search_indexing?(:destroy)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
item.search_index_update_backend
|
item.search_index_update_backend
|
||||||
rescue => e
|
rescue => e
|
||||||
logger.error "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}"
|
logger.error "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}"
|
||||||
tolerance_count += 1
|
tolerance_count += 1
|
||||||
sleep 15
|
sleep 15
|
||||||
raise "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}" if tolerance_count == tolerance
|
raise "Unable to send #{item.class}.find(#{item.id}).search_index_update_backend backend: #{e.inspect}" if tolerance_count == tolerance
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
puts "\t#{[(batch + 1) * batch_size, total].min}/#{total}" # rubocop:disable Rails/Output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue