mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Initial release of Discourse
This commit is contained in:
42
lib/tasks/search.rake
Normal file
42
lib/tasks/search.rake
Normal file
@@ -0,0 +1,42 @@
|
||||
task "search:reindex" => :environment do
|
||||
RailsMultisite::ConnectionManagement.each_connection do |db|
|
||||
puts "Reindexing #{db}"
|
||||
puts ""
|
||||
puts "Posts:"
|
||||
Post.exec_sql("select p.id, p.cooked, c.name category, t.title from
|
||||
posts p
|
||||
join topics t on t.id = p.topic_id
|
||||
left join categories c on c.id = t.category_id
|
||||
").each do |p|
|
||||
post_id = p["id"]
|
||||
cooked = p["cooked"]
|
||||
title = p["title"]
|
||||
category = p["cat"]
|
||||
SearchObserver.update_posts_index(post_id, cooked, title, category)
|
||||
|
||||
putc "."
|
||||
end
|
||||
|
||||
puts
|
||||
puts "Users:"
|
||||
User.exec_sql("select id, name, username from users").each do |u|
|
||||
id = u["id"]
|
||||
name = u["name"]
|
||||
username = u["username"]
|
||||
SearchObserver.update_users_index(id, username, name)
|
||||
|
||||
putc "."
|
||||
end
|
||||
|
||||
puts
|
||||
puts "Categories"
|
||||
|
||||
Category.exec_sql("select id, name from categories").each do |c|
|
||||
id = c["id"]
|
||||
name = c["name"]
|
||||
SearchObserver.update_categories_index(id, name)
|
||||
end
|
||||
|
||||
puts
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user