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.
This commit is contained in:
Juaanma 2015-03-13 23:53:26 -03:00
parent 7bdc62d9b1
commit 9e4b152ec7

View file

@ -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