mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: improve verbose mode for reindexer
This makes the verbose mode provide a bit of progress notification while reindexing as it can take many hours to do a giant site
This commit is contained in:
@@ -60,17 +60,24 @@ module Jobs
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def rebuild_problem_posts(limit: 20000, indexer: SearchIndexer)
|
def rebuild_problem_posts(limit: 20000, indexer: SearchIndexer, verbose: false)
|
||||||
post_ids = load_problem_post_ids(limit)
|
post_ids = load_problem_post_ids(limit)
|
||||||
|
verbose ||= @verbose
|
||||||
|
|
||||||
if @verbose
|
if verbose
|
||||||
puts "rebuilding #{post_ids.length} posts"
|
puts "rebuilding #{post_ids.length} posts"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
i = 0
|
||||||
post_ids.each do |id|
|
post_ids.each do |id|
|
||||||
# could be deleted while iterating through batch
|
# could be deleted while iterating through batch
|
||||||
if post = Post.find_by(id: id)
|
if post = Post.find_by(id: id)
|
||||||
indexer.index(post, force: true)
|
indexer.index(post, force: true)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
if verbose && i % 1000 == 0
|
||||||
|
puts "#{i} posts reindexed"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user