2016-01-19 22:11:52 -06:00
|
|
|
class UserSummarySerializer < ApplicationSerializer
|
2016-04-20 15:58:30 -05:00
|
|
|
|
2017-10-13 15:29:56 -05:00
|
|
|
class TopicSerializer < ListableTopicSerializer
|
|
|
|
attributes :category_id
|
2016-01-19 22:11:52 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
class ReplySerializer < ApplicationSerializer
|
|
|
|
attributes :post_number, :like_count, :created_at
|
|
|
|
has_one :topic, serializer: TopicSerializer
|
|
|
|
end
|
|
|
|
|
2016-04-13 16:02:51 -05:00
|
|
|
class LinkSerializer < ApplicationSerializer
|
2016-04-20 15:58:30 -05:00
|
|
|
attributes :url, :title, :clicks, :post_number
|
|
|
|
has_one :topic, serializer: TopicSerializer
|
|
|
|
|
|
|
|
def post_number
|
|
|
|
object.post.post_number
|
|
|
|
end
|
2016-04-13 16:02:51 -05:00
|
|
|
end
|
|
|
|
|
2016-05-04 15:47:48 -05:00
|
|
|
class UserWithCountSerializer < BasicUserSerializer
|
|
|
|
attributes :count, :name
|
2016-04-13 16:02:51 -05:00
|
|
|
end
|
|
|
|
|
2016-01-19 22:11:52 -06:00
|
|
|
has_many :topics, serializer: TopicSerializer
|
|
|
|
has_many :replies, serializer: ReplySerializer, embed: :object
|
2016-04-13 16:02:51 -05:00
|
|
|
has_many :links, serializer: LinkSerializer, embed: :object
|
2016-05-04 15:47:48 -05:00
|
|
|
has_many :most_liked_by_users, serializer: UserWithCountSerializer, embed: :object
|
|
|
|
has_many :most_liked_users, serializer: UserWithCountSerializer, embed: :object
|
|
|
|
has_many :most_replied_to_users, serializer: UserWithCountSerializer, embed: :object
|
2016-04-20 15:58:30 -05:00
|
|
|
has_many :badges, serializer: UserBadgeSerializer, embed: :object
|
2016-01-19 22:11:52 -06:00
|
|
|
|
2016-03-30 11:05:16 -05:00
|
|
|
attributes :likes_given,
|
|
|
|
:likes_received,
|
|
|
|
:posts_read_count,
|
|
|
|
:days_visited,
|
|
|
|
:topic_count,
|
|
|
|
:post_count,
|
2016-04-13 16:02:51 -05:00
|
|
|
:time_read,
|
2017-11-14 15:39:07 -06:00
|
|
|
:recent_time_read,
|
2016-04-13 16:02:51 -05:00
|
|
|
:bookmark_count
|
2016-03-29 01:11:47 -05:00
|
|
|
|
|
|
|
def include_badges?
|
|
|
|
SiteSetting.enable_badges
|
|
|
|
end
|
2016-03-30 11:05:16 -05:00
|
|
|
|
2016-05-09 08:51:43 -05:00
|
|
|
def include_bookmark_count?
|
|
|
|
scope.authenticated? && object.user_id == scope.user.id
|
|
|
|
end
|
|
|
|
|
2016-03-30 11:05:16 -05:00
|
|
|
def time_read
|
2017-11-14 15:39:07 -06:00
|
|
|
object.time_read
|
|
|
|
end
|
|
|
|
|
|
|
|
def recent_time_read
|
|
|
|
object.recent_time_read
|
2016-03-30 11:05:16 -05:00
|
|
|
end
|
2016-01-19 22:11:52 -06:00
|
|
|
end
|