Skip to content
This repository has been archived by the owner on Jun 24, 2019. It is now read-only.

Commit

Permalink
fix: correctly grant vote badges
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Kruse committed Mar 8, 2016
1 parent 5cc80be commit 8f7b71a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/async/badge_distributor_task.rb
Expand Up @@ -51,15 +51,12 @@ def check_for_owner_vote_badges(user, message)
end

def check_for_voter_badges(vote)
no_upvotes = CfVote.where(user_id: vote.user_id, vtype: CfVote::UPVOTE).count()
no_downvotes = CfVote.where(user_id: vote.user_id, vtype: CfVote::DOWNVOTE).count()

if no_upvotes >= 0
if vote.vtype == CfVote::UPVOTE
b = vote.user.badges.find { |ubadge| ubadge.slug == 'enthusiast' }
give_badge(vote.user, CfBadge.where(slug: 'enthusiast').first!) if b.blank?
end

if no_downvotes >= 0
if vote.vtype == CfVote::DOWNVOTE
b = vote.user.badges.find { |ubadge| ubadge.slug == 'critic' }
give_badge(vote.user, CfBadge.where(slug: 'critic').first!) if b.blank?
end
Expand Down

0 comments on commit 8f7b71a

Please sign in to comment.