2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
class TopicPostCountSerializer < BasicUserSerializer
|
|
|
|
|
2017-01-19 00:37:43 +08:00
|
|
|
attributes :post_count, :primary_group_name,
|
|
|
|
:primary_group_flair_url, :primary_group_flair_color, :primary_group_flair_bg_color
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
def id
|
|
|
|
object[:user].id
|
|
|
|
end
|
|
|
|
|
|
|
|
def username
|
|
|
|
object[:user].username
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_count
|
|
|
|
object[:post_count]
|
|
|
|
end
|
|
|
|
|
2017-01-19 00:37:43 +08:00
|
|
|
def primary_group_name
|
|
|
|
return nil unless object[:user].primary_group_id
|
|
|
|
object[:user]&.primary_group&.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_flair_url
|
|
|
|
object[:user]&.primary_group&.flair_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_flair_bg_color
|
|
|
|
object[:user]&.primary_group&.flair_bg_color
|
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_flair_color
|
|
|
|
object[:user]&.primary_group&.flair_color
|
|
|
|
end
|
|
|
|
|
2013-02-07 23:45:24 +08:00
|
|
|
end
|