From 2dfa6886b44fe642039d9896057f33528a2146a5 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sun, 1 Sep 2024 17:19:18 +0800 Subject: [PATCH] Preparing --- server/database.js | 9 +++++++++ server/jobs/clear-old-data.js | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/server/database.js b/server/database.js index 3374aff9e..76d1139ee 100644 --- a/server/database.js +++ b/server/database.js @@ -711,6 +711,15 @@ class Database { } } + /** + * TODO: Migrate the old data in the heartbeat table to the new format (stat_daily, stat_hourly, stat_minutely) + * It should be run once while upgrading V1 to V2 + * @returns {Promise} + */ + static async migrateAggregateTable() { + + } + } module.exports = Database; diff --git a/server/jobs/clear-old-data.js b/server/jobs/clear-old-data.js index 248a4d409..d74f34845 100644 --- a/server/jobs/clear-old-data.js +++ b/server/jobs/clear-old-data.js @@ -11,6 +11,17 @@ const DEFAULT_KEEP_PERIOD = 180; */ const clearOldData = async () => { + + /* + * TODO: + * Since we have aggregated table now, we don't need so much data in heartbeat table. + * But we still need to keep the important rows, because they contain the message. + * + * In the heartbeat table: + * - important rows: keep according to the setting (keepDataPeriodDays) (default 180 days) + * - not important rows: keep 2 days + */ + let period = await setting("keepDataPeriodDays"); // Set Default Period