Permalink
Browse files

give tedu his karma back

fix bug introduced in 3757b27 that gave comment vote karma to the
voter rather than the commenter
  • Loading branch information...
jcs committed Jan 21, 2014
1 parent 1a0457c commit 3c7393c6a36ef799a9d5c85e1674f6c369f9f9a5
Showing with 8 additions and 1 deletion.
  1. +7 −0 app/models/user.rb
  2. +1 −1 app/models/vote.rb
View
@@ -50,6 +50,13 @@ class User < ActiveRecord::Base
BANNED_USERNAMES = [ "admin", "administrator", "hostmaster", "mailer-daemon",
"postmaster", "root", "security", "support", "webmaster", ]

This comment has been minimized.

Show comment
Hide comment
@kevinburke

kevinburke Jan 21, 2014

"help", "fraud", "contact"

@kevinburke

kevinburke Jan 21, 2014

"help", "fraud", "contact"

def self.recalculate_all_karmas!
User.all.each do |u|
u.karma = u.stories.map(&:score).sum + u.comments.map(&:score).sum
u.save!
end
end
def as_json(options = {})
h = super(:only => [
:username,
View
@@ -131,7 +131,7 @@ def self.vote_thusly_on_story_or_comment_for_user_because(vote, story_id,
if v.comment_id
c = Comment.find(v.comment_id)
if c.user_id != user_id
User.update_counters user_id, :karma => upvote - downvote
User.update_counters c.user_id, :karma => upvote - downvote
end
c.give_upvote_or_downvote_and_recalculate_confidence!(upvote,

0 comments on commit 3c7393c

Please sign in to comment.