mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 21:57:36 +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
32 lines
499 B
Ruby
32 lines
499 B
Ruby
# frozen_string_literal: true
|
|
|
|
class FlaggedTopicSummarySerializer < ActiveModel::Serializer
|
|
|
|
attributes(
|
|
:id,
|
|
:flag_counts,
|
|
:user_ids,
|
|
:last_flag_at
|
|
)
|
|
|
|
has_one :topic, serializer: FlaggedTopicSerializer
|
|
|
|
def id
|
|
topic.id
|
|
end
|
|
|
|
def flag_counts
|
|
object.flag_counts.map do |k, v|
|
|
{ post_action_type_id: k, count: v, name_key: PostActionType.types[k] }
|
|
end
|
|
end
|
|
|
|
def user_ids
|
|
object.user_ids
|
|
end
|
|
|
|
def last_flag_at
|
|
object.last_flag_at
|
|
end
|
|
end
|