From 167bdaff21ca95ad8568bb3e52be9d86c9284421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bla=C5=BEej?= Date: Fri, 7 Jan 2022 20:21:57 +0100 Subject: [PATCH] remove dead code and comments, uptime calculation query bugfix --- server/database.js | 29 +---------------------------- server/model/monitor.js | 4 ++-- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/server/database.js b/server/database.js index dcfad6293..a099e51b6 100644 --- a/server/database.js +++ b/server/database.js @@ -32,33 +32,6 @@ class Database { */ static backupPath = null; - /** - * Add patch filename in key - * Values: - * true: Add it regardless of order - * false: Do nothing - * { parents: []}: Need parents before add it - */ - // static patchList = { - // "patch-setting-value-type.sql": true, - // "patch-improve-performance.sql": true, - // "patch-2fa.sql": true, - // "patch-add-retry-interval-monitor.sql": true, - // "patch-incident-table.sql": true, - // "patch-group-table.sql": true, - // "patch-monitor-push_token.sql": true, - // "patch-http-monitor-method-body-and-headers.sql": true, - // "patch-2fa-invalidate-used-token.sql": true, - // "patch-notification_sent_history.sql": true, - // "patch-monitor-basic-auth.sql": true, - // } - - /** - * The final version should be 10 after merged tag feature - * @deprecated Use patchList for any new feature - */ - static latestVersion = 10; - static noReject = true; static init(args) { @@ -144,7 +117,7 @@ class Database { console.log("Waiting to close the database"); } } - console.log("SQLite closed"); + console.log("Database closed"); process.removeListener("unhandledRejection", listener); } diff --git a/server/model/monitor.js b/server/model/monitor.js index 43899e513..9c70dd389 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -596,7 +596,7 @@ class Monitor extends BeanModel { // including durationBefore (b1 to s), but we need only (s to n) so we have to subtract it let results = await R._knex.select({ - first_status: 'time', + first_status: 'status', first_time: 'time', first_duration: 'duration', total_duration: R._knex.raw('sum(ping)'), @@ -624,7 +624,7 @@ class Monitor extends BeanModel { // subtract uptime_duration and total_duration which is outside the requested duration time window totalDuration -= durationBefore; - if (result.first_status == 1) + if (result.first_status == UP) uptimeDuration -= durationBefore;