adds poll comments to API

This commit is contained in:
Juanjo Bazán
2017-11-21 14:31:03 +01:00
parent ae71f4960b
commit 21b2a11339
3 changed files with 32 additions and 4 deletions

View File

@@ -30,9 +30,11 @@ class Comment < ActiveRecord::Base
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
scope :public_for_api, -> do
where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
(comments.commentable_type = 'Proposal' and comments.commentable_id in (?))},
(comments.commentable_type = 'Proposal' and comments.commentable_id in (?)) or
(comments.commentable_type = 'Poll' and comments.commentable_id in (?))},
Debate.public_for_api.pluck(:id),
Proposal.public_for_api.pluck(:id))
Proposal.public_for_api.pluck(:id),
Poll.public_for_api.pluck(:id))
end
scope :sort_by_most_voted, -> { order(confidence_score: :desc, created_at: :desc) }