fix karma adjustment when not upvoting

This commit is contained in:
joshua stein 2012-09-17 19:24:33 -05:00
parent 40a5f3f8b8
commit 42150c8a56

View file

@ -138,7 +138,8 @@ class Vote < ActiveRecord::Base
if v.comment_id
c = Comment.find(v.comment_id)
if c.user_id != user_id
Keystore.increment_value_for("user:#{c.user_id}:karma")
Keystore.increment_value_for("user:#{c.user_id}:karma",
upvote - downvote)
end
c.give_upvote_or_downvote_and_recalculate_confidence!(upvote,
@ -146,7 +147,8 @@ class Vote < ActiveRecord::Base
else
s = Story.find(v.story_id)
if s.user_id != user_id
Keystore.increment_value_for("user:#{s.user_id}:karma")
Keystore.increment_value_for("user:#{s.user_id}:karma",
upvote - downvote)
end
s.give_upvote_or_downvote_and_recalculate_hotness!(upvote, downvote)