diff --git a/migrations/20130128_remove_dummy_accounts.js b/migrations/20130128_remove_dummy_accounts.js new file mode 100644 index 0000000000..964c307206 --- /dev/null +++ b/migrations/20130128_remove_dummy_accounts.js @@ -0,0 +1,19 @@ +// run with %mongo server:port/dbname node_modules/moment/moment.js migrations/my_commands.js +var unRegistered = { 'auth.local': { $exists: false }, 'auth.facebook': { $exists: false} }, + registered = { $or: [ + { 'auth.local': { $exists: true } }, + { 'auth.facebook': { $exists: true} } + ]}; +db.users.count(registered); +db.users.count(unRegistered); +db.users.find(unRegistered).forEach(function(user) { + var lastCron = new Date(user.lastCron), + today = new Date(), + diff = Math.abs(moment(today).sod().diff(moment(lastCron).sod(), 'days')); + + if (diff > 30) { + db.users.remove({ _id: user._id }); + } +}); +db.users.count(registered); +db.users.count(unRegistered); \ No newline at end of file