Commit 7afb3d18293cb1467a118eb1c3d8939dcc74fd82
1 parent
5cc16711
Exists in
master
Fix vote counting for giving badges
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
lib/ext/entities.rb
@@ -59,7 +59,7 @@ module Merit | @@ -59,7 +59,7 @@ module Merit | ||
59 | action: 'vote#create', | 59 | action: 'vote#create', |
60 | default_threshold: 5, | 60 | default_threshold: 5, |
61 | to: lambda {|vote| vote.voteable.author}, | 61 | to: lambda {|vote| vote.voteable.author}, |
62 | - value: lambda { |vote, author| vote.voteable.profile.identifier == 'conferencia' ? Vote.for_voteable(vote.voteable).where('vote > 0').count : 0 } | 62 | + 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 } |
63 | } | 63 | } |
64 | ], | 64 | ], |
65 | negative_votes_received_conferencia: [ | 65 | negative_votes_received_conferencia: [ |
@@ -67,7 +67,7 @@ module Merit | @@ -67,7 +67,7 @@ module Merit | ||
67 | action: 'vote#create', | 67 | action: 'vote#create', |
68 | default_threshold: 5, | 68 | default_threshold: 5, |
69 | to: lambda {|vote| vote.voteable.author}, | 69 | to: lambda {|vote| vote.voteable.author}, |
70 | - value: lambda { |vote, author| vote.voteable.profile.identifier == 'conferencia' ? Vote.for_voteable(vote.voteable).where('vote < 0').count : 0 } | 70 | + 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 } |
71 | } | 71 | } |
72 | ], | 72 | ], |
73 | votes_performed_conferencia: [ | 73 | votes_performed_conferencia: [ |
@@ -75,7 +75,7 @@ module Merit | @@ -75,7 +75,7 @@ module Merit | ||
75 | action: 'vote#create', | 75 | action: 'vote#create', |
76 | default_threshold: 5, | 76 | default_threshold: 5, |
77 | to: lambda {|vote| vote.voter}, | 77 | to: lambda {|vote| vote.voter}, |
78 | - value: lambda { |vote, voter| vote.voteable.profile.identifier == 'conferencia' ? Vote.for_voter(voter).count : 0} | 78 | + value: lambda { |vote, voter| vote.voteable.profile.identifier == 'conferencia' ? Vote.where(voteable_id: Article.conference_articles.select("articles.id")).for_voter(voter).count : 0} |
79 | } | 79 | } |
80 | ], | 80 | ], |
81 | creative_conferencia: [ | 81 | creative_conferencia: [ |