mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FIX: N+1 query on /categories page
This commit is contained in:
parent
69bc24a16d
commit
7f498a8795
@ -55,7 +55,7 @@ class CategoryList
|
|||||||
# Find a list of all categories to associate the topics with
|
# Find a list of all categories to associate the topics with
|
||||||
def find_categories
|
def find_categories
|
||||||
@categories = Category
|
@categories = Category
|
||||||
.includes(:featured_users, subcategories: [:topic_only_relative_url])
|
.includes(:featured_users, :topic_only_relative_url, subcategories: [:topic_only_relative_url])
|
||||||
.secured(@guardian)
|
.secured(@guardian)
|
||||||
|
|
||||||
if @options[:parent_category_id].present?
|
if @options[:parent_category_id].present?
|
||||||
|
@ -28,6 +28,7 @@ class BasicCategorySerializer < ApplicationSerializer
|
|||||||
def can_edit
|
def can_edit
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_can_edit?
|
def include_can_edit?
|
||||||
scope && scope.can_edit?(object)
|
scope && scope.can_edit?(object)
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ class CategoryDetailedSerializer < BasicCategorySerializer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def include_displayable_topics?
|
def include_displayable_topics?
|
||||||
return displayable_topics.present?
|
displayable_topics.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def description_excerpt
|
def description_excerpt
|
||||||
|
@ -23,6 +23,7 @@ class ListableTopicSerializer < BasicTopicSerializer
|
|||||||
:notification_level
|
:notification_level
|
||||||
|
|
||||||
has_one :last_poster, serializer: BasicUserSerializer, embed: :objects
|
has_one :last_poster, serializer: BasicUserSerializer, embed: :objects
|
||||||
|
|
||||||
def include_last_poster?
|
def include_last_poster?
|
||||||
object.include_last_poster
|
object.include_last_poster
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user