From ba66aadf669f41b9fa19743b269617c6d7602eac Mon Sep 17 00:00:00 2001 From: calzoneman Date: Thu, 26 Sep 2013 23:41:38 -0500 Subject: [PATCH] Move interval stuff to config keys --- changelog | 5 +++++ lib/bgtask.js | 9 ++++----- lib/config.js | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/changelog b/changelog index e4aa04d6..eb9c9ab6 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,8 @@ +Thu Sep 26 23:40 2013 CDT + * lib/config.js: Add config keys for statistics interval & max age, + alias purge interval & max age. + * lib/bgtask.js: Update intervals to reflect new config keys + Thu Sep 26 23:33 2013 CDT * lib/stats.js: Remove this file, move the statistics tracking interval to the new bgtask.js diff --git a/lib/bgtask.js b/lib/bgtask.js index 821c73cc..9b2b9a1b 100644 --- a/lib/bgtask.js +++ b/lib/bgtask.js @@ -23,8 +23,8 @@ var init = null; /* Stats */ function initStats(Server) { - const STAT_INTERVAL = 60 * 60 * 1000; - const STAT_EXPIRE = 24 * STAT_INTERVAL; + var STAT_INTERVAL = Server.cfg["stat-interval"]; + var STAT_EXPIRE = Server.cfg["stat-max-age"]; setInterval(function () { var db = Server.db; @@ -44,11 +44,10 @@ function initStats(Server) { /* Alias cleanup */ function initAliasCleanup(Server) { - const CLEAN_INTERVAL = 60 * 60 * 1000; - const CLEAN_EXPIRE = 30 * 24 * 60 * 60 * 1000; // 1 month + var CLEAN_INTERVAL = Server.cfg["alias-purge-interval"]; + var CLEAN_EXPIRE = Server.cfg["alias-max-age"]; setInterval(function () { - console.log("cleaning aliases"); Server.db.cleanOldAliases(CLEAN_EXPIRE, function (err) { Logger.syslog.log("Cleaned old aliases"); if (err) diff --git a/lib/config.js b/lib/config.js index 92a4b78f..aa29d9ec 100644 --- a/lib/config.js +++ b/lib/config.js @@ -44,7 +44,11 @@ var defaults = { "domain" : "http://localhost", "ytv3apikey" : "", "enable-ytv3" : false, - "ytv2devkey" : "" + "ytv2devkey" : "", + "stat-interval" : 3600000, + "stat-max-age" : 86400000, + "alias-purge-interval": 3600000, + "alias-max-age" : 2592000000 } function save(cfg, file) {