mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-29 02:07:15 +00:00
preen-script: also remove empty parties
This commit is contained in:
parent
67b2174c3d
commit
9361b015f6
1 changed files with 14 additions and 3 deletions
|
|
@ -1,9 +1,10 @@
|
|||
/**
|
||||
* Set this up as a midnight cron script
|
||||
*
|
||||
* mongo habitrpg node_modules/moment/moment.js migrations/20130212_preen_cron.js
|
||||
* mongo habitrpg migrations/preen_cron.js
|
||||
*/
|
||||
|
||||
load('./node_modules/moment/moment.js');
|
||||
|
||||
/*
|
||||
Users are allowed to experiment with the site before registering. Every time a new browser visits habitrpg, a new
|
||||
|
|
@ -11,11 +12,19 @@
|
|||
This function removes all staged accounts that have been abandoned - either older than a month, or corrupted in some way (lastCron==undefined)
|
||||
*/
|
||||
|
||||
var un_registered = {
|
||||
var
|
||||
today = +new Date,
|
||||
|
||||
un_registered = {
|
||||
"auth.local": {$exists: false},
|
||||
"auth.facebook": {$exists: false}
|
||||
},
|
||||
today = +new Date;
|
||||
|
||||
emptyParties = {
|
||||
$where: function(){
|
||||
return this.type === 'party' && this.members.length === 0;
|
||||
}
|
||||
};
|
||||
|
||||
db.users.find(un_registered).forEach(function(user) {
|
||||
//if (!user) return;
|
||||
|
|
@ -29,6 +38,8 @@ db.users.find(un_registered).forEach(function(user) {
|
|||
}
|
||||
});
|
||||
|
||||
db.users.groups.remove(emptyParties);
|
||||
|
||||
|
||||
/**
|
||||
* Don't remove missing user auths anymore. This was previously necessary due to data corruption,
|
||||
|
|
|
|||
Loading…
Reference in a new issue