[#1532] add better validation on preferences.dayStart, and a migration to

cleanup corrupt ones
This commit is contained in:
Tyler Renelle
2013-11-26 15:18:20 -07:00
parent a4fb0b42ad
commit 2b128f71f4
3 changed files with 12 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
db.users.find({'preferences.dayStart':{$exists:1}},{'preferences.dayStart':1}).forEach(function(user){
var dayStart = +user.preferences.dayStart;
dayStart = (_.isNaN(dayStart) || dayStart < 0 || dayStart > 24) ? 0 : dayStart;
db.users.update({_id:user._id}, {$set:{'preferences.dayStart':dayStart}});
});