FEATURE: support multisite configuration for search:reindex task

This commit is contained in:
Arpit Jalan 2016-10-01 08:53:30 +02:00
parent 1302db2683
commit 20c9c60dea

View File

@ -1,6 +1,9 @@
task "search:reindex" => :environment do
RailsMultisite::ConnectionManagement.each_connection do |db|
puts "Reindexing #{db}"
ENV['RAILS_DB'] ? reindex_search : reindex_search_all_sites
end
def reindex_search(db=RailsMultisite::ConnectionManagement.current_db)
puts "Reindexing '#{db}'"
puts ""
puts "Posts:"
Post.exec_sql("select p.id, p.cooked, c.name category, t.title, p.post_number, t.id topic_id from
@ -42,5 +45,10 @@ task "search:reindex" => :environment do
end
puts
end
def reindex_search_all_sites
RailsMultisite::ConnectionManagement.each_connection do |db|
reindex_search(db)
end
end