lila/bin/mongodb/report-room.js
2017-05-11 02:48:52 +02:00

14 lines
444 B
JavaScript

var lastWeek = new Date(Date.now() - 1000 * 60 * 60 * 24 * 7);
db.report.find().forEach(r => {
var room = 'others';
if (!r.processedBy && r.createdAt < lastWeek) room = 'xfiles';
else if (r.reason === 'cheat') room = 'cheat';
else if (r.reason === 'cheatprint') room = 'print';
else if (r.reason === 'troll') room = 'coms';
else if (r.reason === 'insult') room = 'coms';
db.report.update({_id: r._id},{$set:{room: room}});
});