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
|
||||
.includes(featured_topics: [:category])
|
||||
.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
|
||||
|
||||
# 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_topics, serializer: CategoryTopicSerializer, embed: :objects, key: :topics
|
||||
|
|
|
@ -3,7 +3,6 @@ require_dependency 'pinned_check'
|
|||
class CategoryTopicSerializer < ListableTopicSerializer
|
||||
|
||||
attributes :visible, :closed, :archived, :pinned
|
||||
has_one :category
|
||||
|
||||
def pinned
|
||||
PinnedCheck.new(object, object.user_data).pinned?
|
||||
|
|
Loading…
Reference in New Issue