2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-06 09:21:07 -05:00
|
|
|
class FlaggedTopicSummarySerializer < ActiveModel::Serializer
|
2023-01-09 06:20:10 -06:00
|
|
|
attributes(:id, :flag_counts, :user_ids, :last_flag_at)
|
2017-09-06 09:21:07 -05:00
|
|
|
|
|
|
|
has_one :topic, serializer: FlaggedTopicSerializer
|
|
|
|
|
|
|
|
def id
|
|
|
|
topic.id
|
|
|
|
end
|
|
|
|
|
|
|
|
def flag_counts
|
|
|
|
object.flag_counts.map do |k, v|
|
2017-10-17 12:31:45 -05:00
|
|
|
{ post_action_type_id: k, count: v, name_key: PostActionType.types[k] }
|
2017-09-06 09:21:07 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_ids
|
|
|
|
object.user_ids
|
|
|
|
end
|
|
|
|
|
|
|
|
def last_flag_at
|
|
|
|
object.last_flag_at
|
|
|
|
end
|
|
|
|
end
|