|
|
@ -211,9 +211,18 @@ var async = require('async'),
|
|
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
async.parallel({
|
|
|
|
"inboxes": function(next) {
|
|
|
|
"inboxes": function(next) {
|
|
|
|
RDB.keys('uid:*:notifications:unread', next);
|
|
|
|
//RDB.keys('uid:*:notifications:unread', next);
|
|
|
|
|
|
|
|
db.getSortedSetRange('users:joindate', 0, -1, function(err, uids) {
|
|
|
|
|
|
|
|
if(err) {
|
|
|
|
|
|
|
|
return next(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uids = uids.map(function(uid) {
|
|
|
|
|
|
|
|
return 'uid:' + uid + ':notifications:unread';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
next(null, uids);
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"nids": function(next) {
|
|
|
|
"expiredNids": function(next) {
|
|
|
|
db.getSetMembers('notifications', function(err, nids) {
|
|
|
|
db.getSetMembers('notifications', function(err, nids) {
|
|
|
|
async.filter(nids, function(nid, next) {
|
|
|
|
async.filter(nids, function(nid, next) {
|
|
|
|
db.getObjectField('notifications:' + nid, 'datetime', function(err, datetime) {
|
|
|
|
db.getObjectField('notifications:' + nid, 'datetime', function(err, datetime) {
|
|
|
@ -229,14 +238,21 @@ var async = require('async'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function(err, results) {
|
|
|
|
}, function(err, results) {
|
|
|
|
if (!err) {
|
|
|
|
if(err) {
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
|
|
|
|
winston.error('[notifications.prune] Ran into trouble pruning expired notifications. Stack trace to follow.');
|
|
|
|
|
|
|
|
winston.error(err.stack);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var numInboxes = results.inboxes.length,
|
|
|
|
var numInboxes = results.inboxes.length,
|
|
|
|
x;
|
|
|
|
x;
|
|
|
|
|
|
|
|
console.log(results.inboxes, results.expiredNids);
|
|
|
|
async.eachSeries(results.nids, function(nid, next) {
|
|
|
|
async.eachSeries(results.expiredNids, function(nid, next) {
|
|
|
|
var multi = RDB.multi();
|
|
|
|
var multi = RDB.multi();
|
|
|
|
|
|
|
|
|
|
|
|
for(x=0;x<numInboxes;x++) {
|
|
|
|
for(x=0; x<numInboxes; ++x) {
|
|
|
|
multi.zscore(results.inboxes[x], nid);
|
|
|
|
multi.zscore(results.inboxes[x], nid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -260,12 +276,7 @@ var async = require('async'),
|
|
|
|
winston.info('[notifications.prune] Notification pruning completed. ' + numPruned + ' expired notification' + (numPruned !== 1 ? 's' : '') + ' removed.');
|
|
|
|
winston.info('[notifications.prune] Notification pruning completed. ' + numPruned + ' expired notification' + (numPruned !== 1 ? 's' : '') + ' removed.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
|
|
|
|
winston.error('[notifications.prune] Ran into trouble pruning expired notifications. Stack trace to follow.');
|
|
|
|
|
|
|
|
winston.error(err.stack);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|