lila/bin/mongodb/puzzle-migrate-vote-disable.js

17 lines
321 B
JavaScript
Raw Normal View History

2016-12-09 14:02:18 -07:00
var puzzles = db.puzzle;
2016-12-10 05:00:37 -07:00
modified = 0;
puzzles.find().forEach(function(p) {
2016-12-09 14:02:18 -07:00
puzzles.update({
_id: p._id
}, {
$set: {
2016-12-11 12:32:32 -07:00
"vote.ratio": NumberInt(100*(p.vote.up - p.vote.down)/(p.vote.up + p.vote.down)),
"vote.nb": NumberInt(p.vote.up + p.vote.down)
2016-12-09 14:02:18 -07:00
}
});
2016-12-10 05:00:37 -07:00
modified += 1;
2016-12-09 14:02:18 -07:00
});
2016-12-10 05:00:37 -07:00
print(modified);