From b717af8fb96989467b5dd52b2e4f5e30ef7dadfd Mon Sep 17 00:00:00 2001 From: Ionys <9364594+Ionys320@users.noreply.github.com> Date: Fri, 1 Nov 2024 22:30:42 +0100 Subject: [PATCH 1/2] fix(tags): Fix the tag deletion - Add `monitor_tag.value` attribute in `getMonitorTag` SELECT - Add `monitor_id` and `value` for each tag in `preparePreloadData` --- server/model/monitor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 9a30a66896..3ad8cfafc1 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -1522,7 +1522,7 @@ class Monitor extends BeanModel { */ static async getMonitorTag(monitorIDs) { return await R.getAll(` - SELECT monitor_tag.monitor_id, monitor_tag.tag_id, tag.name, tag.color + SELECT monitor_tag.monitor_id, monitor_tag.tag_id, monitor_tag.value, tag.name, tag.color FROM monitor_tag JOIN tag ON monitor_tag.tag_id = tag.id WHERE monitor_tag.monitor_id IN (${monitorIDs.map((_) => "?").join(",")}) @@ -1567,6 +1567,8 @@ class Monitor extends BeanModel { } tagsMap.get(row.monitor_id).push({ tag_id: row.tag_id, + monitor_id: row.monitor_id, + value: row.value, name: row.name, color: row.color }); From bf9a90f4afee0291771d99396349fb7e140428d6 Mon Sep 17 00:00:00 2001 From: Ionys <9364594+Ionys320@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:58:52 +0100 Subject: [PATCH 2/2] fix(status page): Make sure the group deletion is correctly handled when `groupIDList` is empty --- .../status-page-socket-handler.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/socket-handlers/status-page-socket-handler.js b/server/socket-handlers/status-page-socket-handler.js index 0804da15dd..cbcc52b8f4 100644 --- a/server/socket-handlers/status-page-socket-handler.js +++ b/server/socket-handlers/status-page-socket-handler.js @@ -220,13 +220,17 @@ module.exports.statusPageSocketHandler = (socket) => { // Delete groups that are not in the list log.debug("socket", "Delete groups that are not in the list"); - const slots = groupIDList.map(() => "?").join(","); + if (groupIDList.length === 0) { + await R.exec("DELETE FROM `group` WHERE status_page_id = ?", [ statusPage.id ]); + } else { + const slots = groupIDList.map(() => "?").join(","); - const data = [ - ...groupIDList, - statusPage.id - ]; - await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data); + const data = [ + ...groupIDList, + statusPage.id + ]; + await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data); + } const server = UptimeKumaServer.getInstance();