FEATURE: allows to jump to a date in a topic
This commit is contained in:
@@ -12,6 +12,7 @@ class PostsController < ApplicationController
|
||||
:show,
|
||||
:replies,
|
||||
:by_number,
|
||||
:by_date,
|
||||
:short_link,
|
||||
:reply_history,
|
||||
:replyIids,
|
||||
@@ -249,6 +250,11 @@ class PostsController < ApplicationController
|
||||
display_post(post)
|
||||
end
|
||||
|
||||
def by_date
|
||||
post = find_post_from_params_by_date
|
||||
display_post(post)
|
||||
end
|
||||
|
||||
def reply_history
|
||||
post = find_post_from_params
|
||||
render_serialized(post.reply_history(params[:max_replies].to_i, guardian), PostSerializer)
|
||||
@@ -707,6 +713,16 @@ class PostsController < ApplicationController
|
||||
find_post_using(by_number_finder)
|
||||
end
|
||||
|
||||
def find_post_from_params_by_date
|
||||
by_date_finder = TopicView.new(params[:topic_id], current_user)
|
||||
.filtered_posts
|
||||
.where("created_at >= ?", Time.zone.parse(params[:date]))
|
||||
.order("created_at ASC")
|
||||
.limit(1)
|
||||
|
||||
find_post_using(by_date_finder)
|
||||
end
|
||||
|
||||
def find_post_using(finder)
|
||||
# Include deleted posts if the user is staff
|
||||
finder = finder.with_deleted if current_user.try(:staff?)
|
||||
|
||||
Reference in New Issue
Block a user