mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 04:03:52 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
38 lines
749 B
Ruby
38 lines
749 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TopicPostCountSerializer < BasicUserSerializer
|
|
|
|
attributes :post_count, :primary_group_name,
|
|
:primary_group_flair_url, :primary_group_flair_color, :primary_group_flair_bg_color
|
|
|
|
def id
|
|
object[:user].id
|
|
end
|
|
|
|
def username
|
|
object[:user].username
|
|
end
|
|
|
|
def post_count
|
|
object[:post_count]
|
|
end
|
|
|
|
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
|
|
|
|
end
|