mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: memoize to avoid N+1 query in category page
This commit is contained in:
parent
55c0f6a20c
commit
6246dd0aa2
@ -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?
|
||||||
|
Loading…
Reference in New Issue
Block a user