FIX: rake categories:move_topics shouldn't move category description topic (#14797)

This commit is contained in:
Neil Lalonde 2021-11-02 23:27:51 -04:00 committed by GitHub
parent 1fffe941bf
commit 3254d35078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -14,7 +14,12 @@ task "categories:move_topics", [:from_category, :to_category] => [:environment]
if from_category.present? && to_category.present?
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)
Topic
.where(category_id: from_category.id)
.where.not(id: from_category.topic_id)
.update_all(category_id: to_category.id)
from_category.update_attribute(:topic_count, 0)
puts "Updating category stats..."