interim commit, still nothing done

v1.18.x
Julian Lam 11 years ago
parent 3480a1d60e
commit aecbe6d316

@ -128,10 +128,19 @@ var RDB = require('./redis.js'),
},
prune: function(cutoff, callback) {
var today = new Date();
if (!cutoff || !(cutoff instanceof Date)) cutoff = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);
if (!cutoff) cutoff = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);
RDB.smembers('notifications', function(err, nids) {
var cutoffTime = cutoff.getTime();
RDB.smembers('notifications', function(err, nids) {
async.filter(nids, function(nid, next) {
RDB.hget('notifications:' + nid, 'datetime', function(err, datetime) {
if (parseInt(datetime, 10) < cutoffTime) next(true);
else next(false);
});
}, function(expiredNids) {
console.log(expiredNids);
});
});
}
}
@ -141,5 +150,6 @@ module.exports = {
create: notifications.create,
push: notifications.push,
mark_read: notifications.mark_read_multiple,
mark_all_read: notifications.mark_all_read
mark_all_read: notifications.mark_all_read,
prune: notifications.prune
}

@ -0,0 +1,14 @@
var DebugRoute = function(app) {
var Notifications = require('../notifications');
app.namespace('/debug', function() {
app.get('/prune', function(req, res) {
Notifications.prune(new Date(), function() {
console.log('done');
});
res.send();
});
});
};
module.exports = DebugRoute;

@ -656,6 +656,10 @@ var express = require('express'),
});
});
// Debug routes
if (process.env.NODE_ENV === 'development') {
require('./routes/debug')(app);
}
var custom_routes = {
'routes': [],

Loading…
Cancel
Save