mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 03:09:43 +00:00
Exclude recently made invisible topics from the categories list. Also remove a couple n+1 queries.
This commit is contained in:
parent
fe8d2377e8
commit
c6bd6371f2
@ -7,7 +7,8 @@ class CategoryList
|
|||||||
@categories = Category
|
@categories = Category
|
||||||
.includes(featured_topics: [:category])
|
.includes(featured_topics: [:category])
|
||||||
.includes(:featured_users)
|
.includes(:featured_users)
|
||||||
.order('topics_week desc, topics_month desc, topics_year desc')
|
.where('topics.visible' => true)
|
||||||
|
.order('categories.topics_week desc, categories.topics_month desc, categories.topics_year desc')
|
||||||
.to_a
|
.to_a
|
||||||
|
|
||||||
# Support for uncategorized topics
|
# Support for uncategorized topics
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
class CategoryDetailedSerializer < CategorySerializer
|
class CategoryDetailedSerializer < ApplicationSerializer
|
||||||
|
|
||||||
attributes :topic_count, :topics_week, :topics_month, :topics_year
|
attributes :id,
|
||||||
|
:name,
|
||||||
|
:color,
|
||||||
|
:text_color,
|
||||||
|
:slug,
|
||||||
|
:topic_count,
|
||||||
|
:topics_week,
|
||||||
|
:topics_month,
|
||||||
|
:topics_year,
|
||||||
|
:description
|
||||||
|
|
||||||
has_many :featured_users, serializer: BasicUserSerializer
|
has_many :featured_users, serializer: BasicUserSerializer
|
||||||
has_many :featured_topics, serializer: CategoryTopicSerializer, embed: :objects, key: :topics
|
has_many :featured_topics, serializer: CategoryTopicSerializer, embed: :objects, key: :topics
|
||||||
|
@ -3,7 +3,6 @@ require_dependency 'pinned_check'
|
|||||||
class CategoryTopicSerializer < ListableTopicSerializer
|
class CategoryTopicSerializer < ListableTopicSerializer
|
||||||
|
|
||||||
attributes :visible, :closed, :archived, :pinned
|
attributes :visible, :closed, :archived, :pinned
|
||||||
has_one :category
|
|
||||||
|
|
||||||
def pinned
|
def pinned
|
||||||
PinnedCheck.new(object, object.user_data).pinned?
|
PinnedCheck.new(object, object.user_data).pinned?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user