mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
interim commit, still nothing done
This commit is contained in:
@@ -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);
|
||||
|
||||
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
|
||||
}
|
||||
14
src/routes/debug.js
Normal file
14
src/routes/debug.js
Normal file
@@ -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': [],
|
||||
|
||||
Reference in New Issue
Block a user