give tedu his karma back
fix bug introduced in 3757b279
that gave comment vote karma to the
voter rather than the commenter
This commit is contained in:
parent
1a0457c7be
commit
3c7393c6a3
|
@ -50,6 +50,13 @@ class User < ActiveRecord::Base
|
|||
BANNED_USERNAMES = [ "admin", "administrator", "hostmaster", "mailer-daemon",
|
||||
"postmaster", "root", "security", "support", "webmaster", ]
|
||||
|
||||
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,
|
||||
|
|
|
@ -131,7 +131,7 @@ class Vote < ActiveRecord::Base
|
|||
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,
|
||||
|
|
Loading…
Reference in a new issue