mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:52:45 +08:00
Added absolute dates to user list serializer
Added fields last_seen_at, last_emailed_at, and created_at to the admin user list serializer, to allow client applications to use those dates without having to parse the age string. Referred to at: https://meta.discourse.org/t/api-returns-relative-times-instead-of-absolute-time-values
This commit is contained in:
parent
157378bfcc
commit
a45024de6c
|
@ -4,6 +4,9 @@ class AdminUserListSerializer < BasicUserSerializer
|
|||
:active,
|
||||
:admin,
|
||||
:moderator,
|
||||
:last_seen_at,
|
||||
:last_emailed_at,
|
||||
:created_at,
|
||||
:last_seen_age,
|
||||
:last_emailed_age,
|
||||
:created_at_age,
|
||||
|
@ -43,11 +46,21 @@ class AdminUserListSerializer < BasicUserSerializer
|
|||
def can_impersonate
|
||||
scope.can_impersonate?(object)
|
||||
end
|
||||
|
||||
def last_emailed_at
|
||||
return nil if object.last_emailed_at.blank?
|
||||
object.last_emailed_at
|
||||
end
|
||||
|
||||
def last_emailed_age
|
||||
return nil if object.last_emailed_at.blank?
|
||||
AgeWords.age_words(Time.now - object.last_emailed_at)
|
||||
end
|
||||
|
||||
def last_seen_at
|
||||
return nil if object.last_seen_at.blank?
|
||||
object.last_seen_at
|
||||
end
|
||||
|
||||
def last_seen_age
|
||||
return nil if object.last_seen_at.blank?
|
||||
|
@ -58,6 +71,10 @@ class AdminUserListSerializer < BasicUserSerializer
|
|||
return nil if object.user_stat.time_read.blank?
|
||||
AgeWords.age_words(object.user_stat.time_read)
|
||||
end
|
||||
|
||||
def created_at
|
||||
object.created_at
|
||||
end
|
||||
|
||||
def created_at_age
|
||||
AgeWords.age_words(Time.now - object.created_at)
|
||||
|
|
Loading…
Reference in New Issue
Block a user