Show topic and post counts by day/week/month/year on categories page

This commit is contained in:
Neil Lalonde
2013-12-13 15:15:51 -05:00
parent a7a7387da1
commit 49c3482464
10 changed files with 182 additions and 14 deletions

View File

@@ -1,9 +1,15 @@
class CategoryDetailedSerializer < BasicCategorySerializer
attributes :post_count,
attributes :topic_count,
:post_count,
:topics_day,
:topics_week,
:topics_month,
:topics_year,
:posts_day,
:posts_week,
:posts_month,
:posts_year,
:description_excerpt,
:is_uncategorized,
:subcategory_ids
@@ -11,6 +17,7 @@ class CategoryDetailedSerializer < BasicCategorySerializer
has_many :featured_users, serializer: BasicUserSerializer
has_many :displayable_topics, serializer: ListableTopicSerializer, embed: :objects, key: :topics
def topics_week
object.topics_week || 0
end
@@ -23,6 +30,18 @@ class CategoryDetailedSerializer < BasicCategorySerializer
object.topics_year || 0
end
def posts_week
object.posts_week || 0
end
def posts_month
object.posts_month || 0
end
def posts_year
object.posts_year || 0
end
def is_uncategorized
object.id == SiteSetting.uncategorized_category_id
end