mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
clean up of preen_cron, which I'm re-enstating
This commit is contained in:
parent
5776bec545
commit
cc097c32f7
1 changed files with 16 additions and 20 deletions
|
|
@ -12,17 +12,16 @@
|
|||
*/
|
||||
|
||||
var un_registered = {
|
||||
"auth.local": {$exists: false},
|
||||
"auth.facebook": {$exists: false}
|
||||
};
|
||||
var registered = {
|
||||
$or: [
|
||||
{ 'auth.local': { $exists: true }},
|
||||
{ 'auth.facebook': { $exists: true }}
|
||||
]
|
||||
};
|
||||
|
||||
var today = +(new Date);
|
||||
"auth.local": {$exists: false},
|
||||
"auth.facebook": {$exists: false}
|
||||
},
|
||||
registered = {
|
||||
$or: [
|
||||
{ 'auth.local': { $exists: true }},
|
||||
{ 'auth.facebook': { $exists: true }}
|
||||
]
|
||||
},
|
||||
today = +new Date;
|
||||
|
||||
// isValidDate = (d) ->
|
||||
// return false if Object::toString.call(d) isnt "[object Date]"
|
||||
|
|
@ -30,12 +29,9 @@ var today = +(new Date);
|
|||
|
||||
|
||||
db.users.find(un_registered).forEach(function(user) {
|
||||
var diff, lastCron;
|
||||
if (!user) return;
|
||||
if (!!user.lastCron) {
|
||||
lastCron = new Date(user.lastCron);
|
||||
diff = Math.abs(moment(today).startOf('day').diff(moment(lastCron).startOf('day'), "days"));
|
||||
if (diff > 3) {
|
||||
if (Math.abs(moment(today).diff(user.lastCron, 'd')) > 5) {
|
||||
return db.users.remove({_id:user._id});
|
||||
}
|
||||
} else {
|
||||
|
|
@ -49,8 +45,8 @@ db.users.find(un_registered).forEach(function(user) {
|
|||
* revisit if needs be
|
||||
*/
|
||||
/*db.sessions.find().forEach(function(sess){
|
||||
var uid = JSON.parse(sess.session).userId;
|
||||
if (!uid || db.users.count({_id:uid}) === 0) {
|
||||
db.sessions.remove({_id:sess._id});
|
||||
}
|
||||
});*/
|
||||
var uid = JSON.parse(sess.session).userId;
|
||||
if (!uid || db.users.count({_id:uid}) === 0) {
|
||||
db.sessions.remove({_id:sess._id});
|
||||
}
|
||||
});*/
|
||||
Loading…
Reference in a new issue