Commit 1f82a5630995c05334e91cc57d4e49300c9bdd7e

Authored by Hugo Melo
1 parent 8c614360
Exists in master

Check if voter if existent on badge rules

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
lib/ext/entities.rb
... ... @@ -67,7 +67,7 @@ module Merit
67 67 action: 'vote#create',
68 68 default_threshold: 5,
69 69 to: lambda {|vote| vote.voteable.author},
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 }
  70 + 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 }
71 71 }
72 72 ],
73 73 votes_performed_conferencia: [
... ... @@ -75,7 +75,7 @@ module Merit
75 75 action: 'vote#create',
76 76 default_threshold: 5,
77 77 to: lambda {|vote| vote.voter},
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}
  78 + 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}
79 79 }
80 80 ],
81 81 creative_conferencia: [
... ...