From 32f7a0084acbf7c5f0984d55082b320e32a63fb0 Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Sun, 8 Jan 2023 19:09:06 +0000 Subject: [PATCH] Fixed negative retention time values Signed-off-by: Matthew Nickson --- server/jobs/clear-old-data.js | 21 ++++++++----- src/components/settings/MonitorHistory.vue | 6 +++- src/languages/en.js | 2 ++ src/pages/Settings.vue | 36 +++++++++++++++++----- 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/server/jobs/clear-old-data.js b/server/jobs/clear-old-data.js index 0ec5ffa5f..ed80b0f74 100644 --- a/server/jobs/clear-old-data.js +++ b/server/jobs/clear-old-data.js @@ -25,15 +25,20 @@ const DEFAULT_KEEP_PERIOD = 180; parsedPeriod = DEFAULT_KEEP_PERIOD; } - log(`Clearing Data older than ${parsedPeriod} days...`); + if (parsedPeriod < 1) { + log(`Data deletion has been disabled as period is less than 1. Period is ${parsedPeriod} days.`); + } else { - try { - await R.exec( - "DELETE FROM heartbeat WHERE time < DATETIME('now', '-' || ? || ' days') ", - [ parsedPeriod ] - ); - } catch (e) { - log(`Failed to clear old data: ${e.message}`); + log(`Clearing Data older than ${parsedPeriod} days...`); + + try { + await R.exec( + "DELETE FROM heartbeat WHERE time < DATETIME('now', '-' || ? || ' days') ", + [ parsedPeriod ] + ); + } catch (e) { + log(`Failed to clear old data: ${e.message}`); + } } exit(); diff --git a/src/components/settings/MonitorHistory.vue b/src/components/settings/MonitorHistory.vue index c78c6aaf7..afcb7bc9e 100644 --- a/src/components/settings/MonitorHistory.vue +++ b/src/components/settings/MonitorHistory.vue @@ -7,6 +7,7 @@ settings.keepDataPeriodDays, ]) }} + {{ $t("infiniteRetention") }} +
+ {{ $t("dataRetentionTimeError") }} +