discourse/app/serializers/reviewable_score_serializer.rb
Robin Ward b58867b6e9 FEATURE: New 'Reviewable' model to make reviewable items generic
Includes support for flags, reviewable users and queued posts, with REST API
backwards compatibility.

Co-Authored-By: romanrizzi <romanalejandro@gmail.com>
Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
2019-03-28 12:45:10 -04:00

19 lines
539 B
Ruby

require_dependency 'reviewable_score_type_serializer'
class ReviewableScoreSerializer < ApplicationSerializer
attributes :id, :score, :agree_stats
has_one :user, serializer: BasicUserSerializer, root: 'users'
has_one :score_type, serializer: ReviewableScoreTypeSerializer
has_one :reviewable_conversation, serializer: ReviewableConversationSerializer
def agree_stats
{
agreed: user.user_stat.flags_agreed,
disagreed: user.user_stat.flags_disagreed,
ignored: user.user_stat.flags_ignored
}
end
end