mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
Merge pull request #127 from mrcoles/master
Make upvote cleanup prior downvote and vice-versa
This commit is contained in:
commit
3334882989
1 changed files with 16 additions and 2 deletions
18
lib/vote.js
18
lib/vote.js
|
@ -28,11 +28,18 @@
|
|||
|
||||
var votePower=getVotePower(user);
|
||||
var votedItem = collection.findOne(id);
|
||||
var vote = 1;
|
||||
|
||||
if (hasDownvotedItem(user, collection, id)) {
|
||||
vote += 1;
|
||||
votePower *= 2;
|
||||
}
|
||||
|
||||
// Votes & Score
|
||||
collection.update({_id: id},{
|
||||
$addToSet: {upvoters: user._id},
|
||||
$inc: {votes: 1, baseScore: votePower},
|
||||
$pull: {downvoters: user._id},
|
||||
$inc: {votes: vote, baseScore: votePower},
|
||||
$set: {inactive: false}
|
||||
});
|
||||
if(!this.isSimulation)
|
||||
|
@ -56,11 +63,18 @@
|
|||
|
||||
var votePower=getVotePower(user);
|
||||
var votedItem = collection.findOne(id);
|
||||
var vote = -1;
|
||||
|
||||
if (hasUpvotedItem(user, collection, id)) {
|
||||
vote -= 1;
|
||||
votePower *= 2;
|
||||
}
|
||||
|
||||
// Votes & Score
|
||||
collection.update({_id: id},{
|
||||
$addToSet: {downvoters: user._id},
|
||||
$inc: {votes: -1, baseScore: -votePower},
|
||||
$pull: {upvoters: user._id},
|
||||
$inc: {votes: vote, baseScore: -votePower},
|
||||
$set: {inactive: false}
|
||||
});
|
||||
if(!this.isSimulation)
|
||||
|
|
Loading…
Add table
Reference in a new issue