mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 12:26:04 +08:00
PERF: memoize to avoid N+1 query in category page
This commit is contained in:
@ -382,7 +382,8 @@ SQL
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_children?
|
def has_children?
|
||||||
id && Category.where(parent_category_id: id).exists?
|
@has_children ||= (id && Category.where(parent_category_id: id).exists?) ? :true : :false
|
||||||
|
@has_children == :true
|
||||||
end
|
end
|
||||||
|
|
||||||
def uncategorized?
|
def uncategorized?
|
||||||
|
Reference in New Issue
Block a user