From 378c4852194b92a4fb6e1c37709fc1ba0514e209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 5 Aug 2021 11:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=8A=82=E7=82=B9=E5=88=86?= =?UTF-8?q?=E7=BB=84=E4=B8=AD=E8=8A=82=E7=82=B9=E6=95=B0=E9=87=8F=E6=97=B6?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=8A=82=E7=82=B9=E9=9B=86=E7=BE=A4=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/node_dao.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index e95cd91e..b1971911 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -432,9 +432,9 @@ func (this *NodeDAO) FindAllInactiveNodesWithClusterId(tx *dbs.Tx, clusterId int _, err = this.Query(tx). State(NodeStateEnabled). Attr("clusterId", clusterId). - Attr("isOn", true). // 只监控启用的节点 + Attr("isOn", true). // 只监控启用的节点 Attr("isInstalled", true). // 只监控已经安装的节点 - Attr("isActive", true). // 当前已经在线的 + Attr("isActive", true). // 当前已经在线的 Where("(status IS NULL OR (JSON_EXTRACT(status, '$.isActive')=false AND UNIX_TIMESTAMP()-JSON_EXTRACT(status, '$.updatedAt')>10) OR UNIX_TIMESTAMP()-JSON_EXTRACT(status, '$.updatedAt')>120)"). Result("id", "name"). Slice(&result). @@ -941,6 +941,7 @@ func (this *NodeDAO) CountAllEnabledNodesWithGroupId(tx *dbs.Tx, groupId int64) return this.Query(tx). State(NodeStateEnabled). Attr("groupId", groupId). + Where("clusterId IN (SELECT id FROM " + SharedNodeClusterDAO.Table + " WHERE state=1)"). Count() }