mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
minor optimizations to categories:move_topics rake task
This commit is contained in:
parent
62c266f987
commit
e9d92da9ee
1 changed files with 5 additions and 2 deletions
|
@ -10,9 +10,12 @@ task "categories:move_topics", [:from_category, :to_category] => [:environment]
|
||||||
from_category = Category.find(from_category_id)
|
from_category = Category.find(from_category_id)
|
||||||
to_category = Category.find(to_category_id)
|
to_category = Category.find(to_category_id)
|
||||||
|
|
||||||
if from_category && to_category
|
if from_category.present? && to_category.present?
|
||||||
Topic.where(category_id: from_category_id).update_all(category_id: to_category_id)
|
puts "Moving topics from #{from_category.slug} to #{to_category.slug}..."
|
||||||
|
Topic.where(category_id: from_category.id).update_all(category_id: to_category.id)
|
||||||
from_category.update_attribute(:topic_count, 0)
|
from_category.update_attribute(:topic_count, 0)
|
||||||
|
|
||||||
|
puts "Updating category stats..."
|
||||||
Category.update_stats
|
Category.update_stats
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue