Exclude recently made invisible topics from the categories list. Also remove a couple n+1 queries.

This commit is contained in:
Robin Ward 2013-04-05 16:09:27 -04:00
parent fe8d2377e8
commit c6bd6371f2
3 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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?