Top level replies (#16087)

* DEV: Show only top level replies

Adds a new query param to the topic view so that we can filter out posts
that aren't top level replies. If a post is a reply to another post
instead of the original topic post we should not include it in the
response if the `filter_top_level_replies` query param is present.

* add rspec test
This commit is contained in:
Blake Erickson
2022-03-02 13:25:36 -07:00
committed by GitHub
parent ea3a58d051
commit df2441ee37
3 changed files with 33 additions and 2 deletions

View File

@ -860,6 +860,14 @@ class TopicView
@contains_gaps = true
end
# Show Only Top Level Replies
if @filter_top_level_replies.present?
@filtered_posts = @filtered_posts.where('
posts.post_number > 1
AND posts.reply_to_post_number IS NULL
')
end
# Filtering upwards
if @filter_upwards_post_id.present?
post = Post.find(@filter_upwards_post_id)