discourse/app/serializers/flagged_topic_summary_serializer.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
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
2019-05-13 09:31:32 +08:00

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