bug fixes for user_stat extraction, decrease querying

This commit is contained in:
Sam
2013-10-04 18:06:32 +10:00
parent e18b93026a
commit 094b5eccca
6 changed files with 22 additions and 13 deletions

View File

@@ -8,8 +8,19 @@ class InvitedUserSerializer < BasicUserSerializer
:days_since_created
def time_read
return nil if object.time_read.blank?
AgeWords.age_words(object.time_read)
AgeWords.age_words(object.user_stat.time_read)
end
def days_visited
object.user_stat.days_visited
end
def topics_entered
object.user_stat.topics_entered
end
def posts_read_count
object.user_stat.posts_read_count
end
def days_since_created

View File

@@ -13,7 +13,7 @@ module PostStreamSerializerMixin
return @posts if @posts.present?
@posts = []
@highest_number_in_posts = 0
if object.posts.present?
if object.posts
object.posts.each_with_index do |p, idx|
@highest_number_in_posts = p.post_number if p.post_number > @highest_number_in_posts
ps = PostSerializer.new(p, scope: scope, root: false)