From 1f82a5630995c05334e91cc57d4e49300c9bdd7e Mon Sep 17 00:00:00 2001 From: Hugo Melo Date: Mon, 2 Nov 2015 14:51:53 -0200 Subject: [PATCH] Check if voter if existent on badge rules --- lib/ext/entities.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ext/entities.rb b/lib/ext/entities.rb index 8db5daf..5f5ee29 100644 --- a/lib/ext/entities.rb +++ b/lib/ext/entities.rb @@ -67,7 +67,7 @@ module Merit action: 'vote#create', default_threshold: 5, to: lambda {|vote| vote.voteable.author}, - value: lambda { |vote, author| vote.voteable.profile.identifier == 'conferencia' ? Vote.where(voteable_id: Article.conference_articles.select("articles.id")).for_voteable(vote.voteable).where('vote < 0').count : 0 } + value: lambda { |vote, author| (vote.voteable.profile.identifier == 'conferencia' and author.present?) ? Vote.where(voteable_id: Article.conference_articles.select("articles.id")).for_voteable(vote.voteable).where('vote < 0').count : 0 } } ], votes_performed_conferencia: [ @@ -75,7 +75,7 @@ module Merit action: 'vote#create', default_threshold: 5, to: lambda {|vote| vote.voter}, - value: lambda { |vote, voter| vote.voteable.profile.identifier == 'conferencia' ? Vote.where(voteable_id: Article.conference_articles.select("articles.id")).for_voter(voter).count : 0} + value: lambda { |vote, voter| (vote.voteable.profile.identifier == 'conferencia' and voter.present?) ? Vote.where(voteable_id: Article.conference_articles.select("articles.id")).for_voter(voter).count : 0} } ], creative_conferencia: [ -- libgit2 0.21.2