FEATURE: Topic timeline widget

This commit is contained in:
Robin Ward
2016-05-17 13:03:08 -04:00
parent 751e354ca6
commit 559fa36c18
27 changed files with 621 additions and 102 deletions

View File

@ -311,7 +311,6 @@ class TopicView
@filtered_posts.by_newest.with_user.first(25)
end
def current_post_ids
@current_post_ids ||= if @posts.is_a?(Array)
@posts.map {|p| p.id }
@ -320,8 +319,17 @@ class TopicView
end
end
# Returns an array of [id, post_number, days_ago] tuples. `days_ago` is there for the timeline
# calculations.
def filtered_post_stream
@filtered_post_stream ||= @filtered_posts.order(:sort_order)
.pluck(:id,
:post_number,
'EXTRACT(DAYS FROM CURRENT_TIMESTAMP - created_at)::INT AS days_ago')
end
def filtered_post_ids
@filtered_post_ids ||= filter_post_ids_by(:sort_order)
@filtered_post_ids ||= filtered_post_stream.map {|tuple| tuple[0]}
end
protected
@ -435,11 +443,6 @@ class TopicView
raise Discourse::InvalidAccess.new("can't see #{@topic}", @topic) unless guardian.can_see?(@topic)
end
def filter_post_ids_by(sort_order)
@filtered_posts.order(sort_order).pluck(:id)
end
def get_minmax_ids(post_number)
# Find the closest number we have
closest_index = closest_post_to(post_number)