mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 09:39:23 +00:00
add remove_dummy_acounts migration
This commit is contained in:
parent
c4f0ec7ce0
commit
e747e8f2b9
1 changed files with 19 additions and 0 deletions
19
migrations/20130128_remove_dummy_accounts.js
Normal file
19
migrations/20130128_remove_dummy_accounts.js
Normal file
|
|
@ -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);
|
||||
Loading…
Reference in a new issue