2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
class InvitedUserSerializer < BasicUserSerializer
|
|
|
|
|
2013-02-07 23:45:24 +08:00
|
|
|
attributes :topics_entered,
|
|
|
|
:posts_read_count,
|
|
|
|
:last_seen_at,
|
|
|
|
:time_read,
|
2013-02-06 03:16:51 +08:00
|
|
|
:days_visited,
|
|
|
|
:days_since_created
|
|
|
|
|
2014-03-22 02:13:04 +08:00
|
|
|
attr_accessor :invited_by
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
def time_read
|
2017-11-18 06:08:49 +08:00
|
|
|
object.user_stat.time_read
|
2013-10-04 16:06:32 +08:00
|
|
|
end
|
|
|
|
|
2014-03-22 02:13:04 +08:00
|
|
|
def include_time_read?
|
|
|
|
scope.can_see_invite_details?(invited_by)
|
|
|
|
end
|
|
|
|
|
2013-10-04 16:06:32 +08:00
|
|
|
def days_visited
|
|
|
|
object.user_stat.days_visited
|
|
|
|
end
|
|
|
|
|
2014-03-22 02:13:04 +08:00
|
|
|
def include_days_visited?
|
|
|
|
scope.can_see_invite_details?(invited_by)
|
|
|
|
end
|
|
|
|
|
2013-10-04 16:06:32 +08:00
|
|
|
def topics_entered
|
|
|
|
object.user_stat.topics_entered
|
|
|
|
end
|
|
|
|
|
2014-03-22 02:13:04 +08:00
|
|
|
def include_topics_entered?
|
|
|
|
scope.can_see_invite_details?(invited_by)
|
|
|
|
end
|
|
|
|
|
2013-10-04 16:06:32 +08:00
|
|
|
def posts_read_count
|
|
|
|
object.user_stat.posts_read_count
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2014-03-22 02:13:04 +08:00
|
|
|
def include_posts_read_count?
|
|
|
|
scope.can_see_invite_details?(invited_by)
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
def days_since_created
|
|
|
|
((Time.now - object.created_at) / 60 / 60 / 24).ceil
|
|
|
|
end
|
|
|
|
|
2014-03-22 02:13:04 +08:00
|
|
|
def include_days_since_created
|
|
|
|
scope.can_see_invite_details?(invited_by)
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|