Make topic lists show last activity more intuitively

This commit is contained in:
tms
2013-02-18 00:17:50 -05:00
parent 8ce9eefdce
commit 172173eccc
6 changed files with 28 additions and 31 deletions

View File

@@ -8,6 +8,9 @@ class ListableTopicSerializer < BasicTopicSerializer
:image_url,
:created_at,
:last_posted_at,
:bumped,
:bumped_at,
:bumped_age,
:age,
:unseen,
:last_read_post_number,
@@ -18,6 +21,16 @@ class ListableTopicSerializer < BasicTopicSerializer
def age
AgeWords.age_words(Time.now - (object.created_at || Time.now))
end
def bumped
object.created_at < object.bumped_at
end
def bumped_age
return nil if object.bumped_at.blank?
AgeWords.age_words(Time.now - object.bumped_at)
end
alias include_bumped_age? :bumped
def seen
object.user_data.present?

View File

@@ -1,11 +1,6 @@
class SuggestedTopicSerializer < ListableTopicSerializer
attributes :archetype, :like_count, :views, :last_post_age
attributes :archetype, :like_count, :views
has_one :category, embed: :objects
def last_post_age
return nil if object.last_posted_at.blank?
AgeWords.age_words(Time.now - object.last_posted_at)
end
end

View File

@@ -8,7 +8,6 @@ class TopicListItemSerializer < ListableTopicSerializer
:pinned,
:closed,
:archived,
:last_post_age,
:starred,
:has_best_of,
:archetype
@@ -16,11 +15,6 @@ class TopicListItemSerializer < ListableTopicSerializer
has_one :category
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
def last_post_age
return nil if object.last_posted_at.blank?
AgeWords.age_words(Time.now - object.last_posted_at)
end
def starred
object.user_data.starred?
end