refactors proposal_notification.public_for_api
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class ProposalNotification < ActiveRecord::Base
|
||||
|
||||
include Graphqlable
|
||||
|
||||
|
||||
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :proposal
|
||||
|
||||
@@ -10,7 +10,7 @@ class ProposalNotification < ActiveRecord::Base
|
||||
validates :proposal, presence: true
|
||||
validate :minimum_interval
|
||||
|
||||
scope :public_for_api, -> { joins(:proposal).where("proposals.hidden_at IS NULL") }
|
||||
scope :public_for_api, -> { where(proposal_id: Proposal.public_for_api.pluck(:id)) }
|
||||
|
||||
def minimum_interval
|
||||
return true if proposal.try(:notifications).blank?
|
||||
|
||||
Reference in New Issue
Block a user