From 7afb3d18293cb1467a118eb1c3d8939dcc74fd82 Mon Sep 17 00:00:00 2001 From: Hugo Melo Date: Fri, 16 Oct 2015 16:11:41 -0300 Subject: [PATCH] Fix vote counting for giving badges --- lib/ext/entities.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ext/entities.rb b/lib/ext/entities.rb index 3bb664b..df2aeea 100644 --- a/lib/ext/entities.rb +++ b/lib/ext/entities.rb @@ -59,7 +59,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.for_voteable(vote.voteable).where('vote > 0').count : 0 } + 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 } } ], negative_votes_received_conferencia: [ @@ -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.for_voteable(vote.voteable).where('vote < 0').count : 0 } + 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 } } ], 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.for_voter(voter).count : 0} + value: lambda { |vote, voter| vote.voteable.profile.identifier == 'conferencia' ? Vote.where(voteable_id: Article.conference_articles.select("articles.id")).for_voter(voter).count : 0} } ], creative_conferencia: [ -- libgit2 0.21.2