2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-19 08:50:00 -05:00
|
|
|
class PollOptionSerializer < ApplicationSerializer
|
|
|
|
|
|
|
|
attributes :id, :html, :votes
|
|
|
|
|
|
|
|
def id
|
|
|
|
object.digest
|
|
|
|
end
|
|
|
|
|
|
|
|
def votes
|
|
|
|
# `size` instead of `count` to prevent N+1
|
|
|
|
object.poll_votes.size + object.anonymous_votes.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|