Files
nairobi/app/models/vote.rb

17 lines
608 B
Ruby

class Vote < ActsAsVotable::Vote
include Graphqlable
scope :public_for_api, -> do
where(%{(votes.votable_type = 'Debate' and votes.votable_id in (?)) or
(votes.votable_type = 'Proposal' and votes.votable_id in (?)) or
(votes.votable_type = 'Comment' and votes.votable_id in (?)) or
(votes.votable_type = 'LegislationProposal' and votes.votable_id in (?))},
Debate.public_for_api.pluck(:id),
Proposal.public_for_api.pluck(:id),
Comment.public_for_api.pluck(:id),
Legislation::Proposal.public_for_api.pluck(:id))
end
end