discourse/app/serializers/reviewable_score_serializer.rb

20 lines
646 B
Ruby
Raw Normal View History

require_dependency 'reviewable_score_type_serializer'
class ReviewableScoreSerializer < ApplicationSerializer
2019-04-09 16:43:08 -04:00
attributes :id, :score, :agree_stats, :status, :created_at, :reviewed_at
has_one :user, serializer: BasicUserSerializer, root: 'users'
has_one :score_type, serializer: ReviewableScoreTypeSerializer
has_one :reviewable_conversation, serializer: ReviewableConversationSerializer
2019-04-09 16:43:08 -04:00
has_one :reviewed_by, serializer: BasicUserSerializer, root: 'users'
def agree_stats
{
agreed: user.user_stat.flags_agreed,
disagreed: user.user_stat.flags_disagreed,
ignored: user.user_stat.flags_ignored
}
end
end