2019-01-03 12:03:01 -05:00
|
|
|
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
|
2019-01-03 12:03:01 -05:00
|
|
|
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'
|
2019-01-03 12:03:01 -05:00
|
|
|
|
|
|
|
def agree_stats
|
|
|
|
{
|
|
|
|
agreed: user.user_stat.flags_agreed,
|
|
|
|
disagreed: user.user_stat.flags_disagreed,
|
|
|
|
ignored: user.user_stat.flags_ignored
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|