PERF: Don't pluck all the columns just to retrieve a single value.

This commit is contained in:
Guo Xiang Tan
2018-06-27 11:11:22 +08:00
parent 7dce8290ed
commit cb69888758
5 changed files with 42 additions and 25 deletions

View File

@@ -186,10 +186,8 @@ class TopicViewSerializer < ApplicationSerializer
end
def last_read_post_id
return nil unless object.filtered_post_stream && last_read_post_number
object.filtered_post_stream.each do |ps|
return ps[0] if ps[1] === last_read_post_number
end
return nil unless last_read_post_number
object.last_read_post_id(last_read_post_number)
end
alias_method :include_last_read_post_id?, :has_topic_user?