From 9e4b152ec79e2d3c1560d0b2c0cd397c61045ccb Mon Sep 17 00:00:00 2001 From: Juaanma Date: Fri, 13 Mar 2015 23:53:26 -0300 Subject: [PATCH] Correct base score calculation in vote.js When we downvote an item or cancel one of its upvotes, we should decrese, not increase, the base score. --- lib/vote.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vote.js b/lib/vote.js index 880a629ef..3d118d798 100644 --- a/lib/vote.js +++ b/lib/vote.js @@ -147,7 +147,7 @@ downvoteItem = function (collection, item, user) { addVote(user._id, vote, collectionName, 'down'); // extend item with baseScore to help calculate newScore - item = _.extend(item, {baseScore: (item.baseScore + votePower)}); + item = _.extend(item, {baseScore: (item.baseScore - votePower)}); updateScore({collection: collection, item: item, forceUpdate: true}); // if the item is being upvoted by its own author, don't give karma @@ -201,7 +201,7 @@ cancelUpvote = function (collection, item, user) { removeVote(user._id, item._id, collectionName, 'up'); // extend item with baseScore to help calculate newScore - item = _.extend(item, {baseScore: (item.baseScore + votePower)}); + item = _.extend(item, {baseScore: (item.baseScore - votePower)}); updateScore({collection: collection, item: item, forceUpdate: true}); // if the item is being upvoted by its own author, don't give karma