Do not show proposals and investments as recommended when already followed

This commit is contained in:
taitus
2017-07-21 22:58:49 +02:00
parent a4e12ea801
commit e82e8f5787

View File

@@ -320,14 +320,18 @@ class User < ActiveRecord::Base
end
def recommended_proposals
already_followed_proposals_ids = Proposal.joins(:follows).where("follows.user_id = ?", id).pluck(:id)
Proposal.tagged_with(interests, any: true).
where("author_id != ?", self).
where("author_id != ? AND id NOT IN (?)", id, already_followed_proposals_ids).
order("cached_votes_up DESC").limit(3)
end
def recommended_budget_investments
already_followed_investments_ids = Budget::Investment.joins(:follows).where("follows.user_id = ?", id).pluck(:id)
Budget::Investment.tagged_with(interests, any: true).
where("author_id != ?", self).
where("author_id != ? AND id NOT IN (?)", id, already_followed_investments_ids).
order("cached_votes_up DESC").limit(3)
end