mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
DEV: Prefer nested queries (#23464)
Some sites have a large number of categories and fetching the category IDs or category topic IDs just to build another query can take a long time or resources (i.e. memory).
This commit is contained in:
@ -344,7 +344,7 @@ class TopicsController < ApplicationController
|
||||
topic = Topic.find_by(id: params[:id])
|
||||
guardian.ensure_can_edit!(topic)
|
||||
|
||||
category = Category.where(id: params[:category_id].to_i).first
|
||||
category = Category.find_by(id: params[:category_id].to_i)
|
||||
guardian.ensure_can_publish_topic!(topic, category)
|
||||
|
||||
row_count = SharedDraft.where(topic_id: topic.id).update_all(category_id: category.id)
|
||||
|
Reference in New Issue
Block a user