more fixing of puzzle vote migration

This commit is contained in:
James Clarke 2016-12-10 23:00:37 +11:00
parent 8bf63b9fb8
commit 085f1f7051

View file

@ -1,13 +1,20 @@
var puzzles = db.puzzle; var puzzles = db.puzzle;
puzzles.find({}).forEach(function(p) { modified = 0;
puzzles.find().forEach(function(p) {
puzzles.update({ puzzles.update({
_id: p._id _id: p._id
}, { }, {
$set: { $set: {
vote: { vote: {
enabled: (p.vote.up * 3 > p.vote.down) || (p.vote.up + p.vote.down < 50) enabled: (p.vote.up * 3 > p.vote.down) || (p.vote.up + p.vote.down < 50),
up: p.vote.up,
down: p.vote.down
} }
} }
}); });
modified += 1;
}); });
print(modified);