FEATURE: add `topic_filtered_posts_count` attribute to web hook post serializer.

This commit is contained in:
Vinoth Kannan 2019-12-04 22:52:44 +05:30
parent c5140ef3fb
commit 400f79cffc
1 changed files with 5 additions and 0 deletions

View File

@ -3,6 +3,7 @@
class WebHookPostSerializer < PostSerializer
attributes :topic_posts_count,
:topic_filtered_posts_count,
:topic_archetype,
:category_slug
@ -34,6 +35,10 @@ class WebHookPostSerializer < PostSerializer
object.topic ? object.topic.posts_count : 0
end
def topic_filtered_posts_count
object.topic ? object.topic.posts.where(post_type: Post.types[:regular]).count : 0
end
def topic_archetype
object.topic ? object.topic.archetype : ''
end