delete eventlog older than 7 days

This commit is contained in:
Girish Ramakrishnan
2016-07-25 12:36:43 -07:00
parent 338f4bcdea
commit 98facf2a3c
6 changed files with 70 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ exports = module.exports = {
add: add,
get: get,
getAllPaged: getAllPaged,
cleanup: cleanup,
// keep in sync with webadmin index.js filter
ACTION_ACTIVATE: 'cloudron.activate',
@@ -100,3 +101,16 @@ function getAllPaged(action, search, page, perPage, callback) {
callback(null, boxes);
});
}
function cleanup(callback) {
callback = callback || NOOP_CALLBACK;
var d = new Date();
d.setDate(d.getDate() - 7); // 7 days ago
eventlogdb.delByCreationTime(d, function (error) {
if (error) return callback(new EventLogError(EventLogError.INTERNAL_ERROR, error));
callback(null);
});
}