Fix the build.

This commit is contained in:
Guo Xiang Tan 2017-09-07 18:41:44 +08:00
parent 3e123b1a39
commit e0d5d9670a
2 changed files with 3 additions and 11 deletions

View File

@ -59,7 +59,7 @@ class FilterBestPosts
end
def sort_posts
@posts.to_a.sort! { |a, b| a.post_number <=> b.post_number }
@posts = Post.from(@posts, :posts).order(post_number: :asc)
end
end

View File

@ -66,7 +66,7 @@ class TopicView
filter_posts(options)
if @posts
if @posts.present?
if (added_fields = User.whitelisted_user_custom_fields(@guardian)).present?
@user_custom_fields = User.custom_fields_for_ids(@posts.pluck(:user_id), added_fields)
end
@ -331,14 +331,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 }
else
@posts.pluck(:post_number)
end
end
# Returns an array of [id, post_number, days_ago] tuples.
# `days_ago` is there for the timeline calculations.
def filtered_post_stream
@ -361,7 +353,7 @@ class TopicView
post_numbers = PostTiming
.where(topic_id: @topic.id, user_id: @user.id)
.where(post_number: current_post_ids)
.where(post_number: @posts.pluck(:post_number))
.pluck(:post_number)
post_numbers.each { |pn| result << pn }