Node.js based forum software built for the modern web
interim commit, still nothing done
Julian Lamaecbe6d316db
diff --git a/src/notifications.js b/src/notifications.jsindex e327e4c59f..fe92a1c9ed 100644--- a/src/notifications.js+++ b/src/notifications.js@@ -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}\ No newline at end of filediff --git a/src/routes/debug.js b/src/routes/debug.jsnew file mode 100644index 0000000000..5b9298c42e--- /dev/null+++ b/src/routes/debug.js@@ -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;\ No newline at end of filediff --git a/src/webserver.js b/src/webserver.jsindex e216c6ebfa..b660f34372 100644--- a/src/webserver.js+++ b/src/webserver.js@@ -656,6 +656,10 @@ var express = require('express'),});});+ // Debug routes+ if (process.env.NODE_ENV === 'development') {+ require('./routes/debug')(app);+ }var custom_routes = {'routes': [],