Simplify methods to get API-public records
Just like we did to tags in commit 2e863fdc5.
This commit is contained in:
@@ -37,12 +37,7 @@ class Comment < ApplicationRecord
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :public_for_api, -> do
|
||||
not_valuations
|
||||
.where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
|
||||
(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),
|
||||
Poll.public_for_api.pluck(:id))
|
||||
.where(commentable: [Debate.public_for_api, Proposal.public_for_api, Poll.public_for_api])
|
||||
end
|
||||
|
||||
scope :sort_by_most_voted, -> { order(confidence_score: :desc, created_at: :desc) }
|
||||
|
||||
@@ -10,7 +10,7 @@ class ProposalNotification < ApplicationRecord
|
||||
validates :proposal, presence: true
|
||||
validate :minimum_interval
|
||||
|
||||
scope :public_for_api, -> { where(proposal_id: Proposal.public_for_api.pluck(:id)) }
|
||||
scope :public_for_api, -> { where(proposal: Proposal.public_for_api) }
|
||||
scope :sort_by_created_at, -> { reorder(created_at: :desc) }
|
||||
scope :sort_by_moderated, -> { reorder(moderated: :desc) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user