Skip to content

A platform for community discussion. Free, open, simple.

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

Vinoth Kannan400f79cffcb8
diff --git a/app/serializers/web_hook_post_serializer.rb b/app/serializers/web_hook_post_serializer.rb
index 030b55203b7..2099a17c4cf 100644
--- a/app/serializers/web_hook_post_serializer.rb
+++ b/app/serializers/web_hook_post_serializer.rb
@@ -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