A platform for community discussion. Free, open, simple.
PERF: Perform only one category update when creating a new topic (#19361)
jbrw64b781dacfd9
diff --git a/lib/post_creator.rb b/lib/post_creator.rbindex 6aa6e478515..2cf45b0a8f4 100644--- a/lib/post_creator.rb+++ b/lib/post_creator.rb@@ -425,8 +425,11 @@ class PostCreatordef track_latest_on_categoryreturn unless @post && @post.errors.count == 0 && @topic && @topic.category_id- Category.where(id: @topic.category_id).update_all(latest_post_id: @post.id)- Category.where(id: @topic.category_id).update_all(latest_topic_id: @topic.id) if @post.is_first_post?+ if @post.is_first_post?+ Category.where(id: @topic.category_id).update_all(latest_topic_id: @topic.id, latest_post_id: @post.id)+ else+ Category.where(id: @topic.category_id).update_all(latest_post_id: @post.id)+ endenddef ensure_in_allowed_users