mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +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:
@ -20,7 +20,7 @@ class AboutController < ApplicationController
|
||||
unless current_user.staff?
|
||||
RateLimiter.new(current_user, "live_post_counts", 1, 10.minutes).performed!
|
||||
end
|
||||
category_topic_ids = Category.pluck(:topic_id).compact!
|
||||
category_topic_ids = Category.select(:topic_id).where.not(topic_id: nil)
|
||||
public_topics =
|
||||
Topic.listable_topics.visible.secured(Guardian.new(nil)).where.not(id: category_topic_ids)
|
||||
stats = { public_topic_count: public_topics.count }
|
||||
|
Reference in New Issue
Block a user