mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
delete anything older than 1 week
This commit is contained in:
@@ -277,21 +277,17 @@ var async = require('async'),
|
|||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Notifications.prune = function(cutoff) {
|
Notifications.prune = function() {
|
||||||
var start = process.hrtime();
|
var start = process.hrtime();
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
winston.info('[notifications.prune] Removing expired notifications from the database.');
|
winston.info('[notifications.prune] Removing expired notifications from the database.');
|
||||||
}
|
}
|
||||||
|
|
||||||
var today = new Date(),
|
var week = 604800000,
|
||||||
numPruned = 0;
|
numPruned = 0;
|
||||||
|
|
||||||
if (!cutoff) {
|
var cutoffTime = Date.now() - week;
|
||||||
cutoff = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);
|
|
||||||
}
|
|
||||||
|
|
||||||
var cutoffTime = cutoff.getTime();
|
|
||||||
|
|
||||||
db.getSetMembers('notifications', function(err, nids) {
|
db.getSetMembers('notifications', function(err, nids) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user