diff --git a/server/jobs/clear-old-data.js b/server/jobs/clear-old-data.js index 956be10e..fcdeac18 100644 --- a/server/jobs/clear-old-data.js +++ b/server/jobs/clear-old-data.js @@ -13,6 +13,9 @@ const DEFAULT_KEEP_PERIOD = 180; const clearOldData = async () => { + // TODO: Temporary disable for testing + return; + /* * TODO: * Since we have aggregated table now, we don't need so much data in heartbeat table. diff --git a/server/uptime-calculator.js b/server/uptime-calculator.js index 5b27fe6f..916f4c4c 100644 --- a/server/uptime-calculator.js +++ b/server/uptime-calculator.js @@ -305,37 +305,40 @@ class UptimeCalculator { } await R.store(dailyStatBean); - let hourlyStatBean = await this.getHourlyStatBean(hourlyKey); - hourlyStatBean.up = hourlyData.up; - hourlyStatBean.down = hourlyData.down; - hourlyStatBean.ping = hourlyData.avgPing; - hourlyStatBean.pingMin = hourlyData.minPing; - hourlyStatBean.pingMax = hourlyData.maxPing; - { - // eslint-disable-next-line no-unused-vars - const { up, down, avgPing, minPing, maxPing, timestamp, ...extras } = hourlyData; - if (Object.keys(extras).length > 0) { - hourlyStatBean.extras = JSON.stringify(extras); + // TODO: For migration mode, we don't need to store old hourly and minutely data, but we need 24-hour's minutely data and 30-day's hourly data + if (false) { + let hourlyStatBean = await this.getHourlyStatBean(hourlyKey); + hourlyStatBean.up = hourlyData.up; + hourlyStatBean.down = hourlyData.down; + hourlyStatBean.ping = hourlyData.avgPing; + hourlyStatBean.pingMin = hourlyData.minPing; + hourlyStatBean.pingMax = hourlyData.maxPing; + { + // eslint-disable-next-line no-unused-vars + const { up, down, avgPing, minPing, maxPing, timestamp, ...extras } = hourlyData; + if (Object.keys(extras).length > 0) { + hourlyStatBean.extras = JSON.stringify(extras); + } } - } - await R.store(hourlyStatBean); - - let minutelyStatBean = await this.getMinutelyStatBean(divisionKey); - minutelyStatBean.up = minutelyData.up; - minutelyStatBean.down = minutelyData.down; - minutelyStatBean.ping = minutelyData.avgPing; - minutelyStatBean.pingMin = minutelyData.minPing; - minutelyStatBean.pingMax = minutelyData.maxPing; - { - // eslint-disable-next-line no-unused-vars - const { up, down, avgPing, minPing, maxPing, timestamp, ...extras } = minutelyData; - if (Object.keys(extras).length > 0) { - minutelyStatBean.extras = JSON.stringify(extras); + await R.store(hourlyStatBean); + + let minutelyStatBean = await this.getMinutelyStatBean(divisionKey); + minutelyStatBean.up = minutelyData.up; + minutelyStatBean.down = minutelyData.down; + minutelyStatBean.ping = minutelyData.avgPing; + minutelyStatBean.pingMin = minutelyData.minPing; + minutelyStatBean.pingMax = minutelyData.maxPing; + { + // eslint-disable-next-line no-unused-vars + const { up, down, avgPing, minPing, maxPing, timestamp, ...extras } = minutelyData; + if (Object.keys(extras).length > 0) { + minutelyStatBean.extras = JSON.stringify(extras); + } } + await R.store(minutelyStatBean); } - await R.store(minutelyStatBean); - // TODO: it seems that it is also necessary to remove the old data in the migration mode + // No need to remove old data in migration mode if (!this.migrationMode) { // Remove the old data log.debug("uptime-calc", "Remove old data");