mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FEATURE: Topic timeline widget
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user