From 262f8a5594c6c8ae32da9fb82382b7ccfe56fc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 12 Jun 2023 14:04:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E5=81=9C=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E4=B8=8D=E6=8F=90=E7=A4=BA=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/api_node_dao.go | 1 + internal/db/models/authority/authority_node_dao.go | 1 + internal/db/models/monitor_node_dao.go | 1 + internal/db/models/node_dao.go | 2 ++ internal/db/models/ns_node_dao.go | 2 ++ internal/db/models/user_node_dao.go | 1 + 6 files changed, 8 insertions(+) diff --git a/internal/db/models/api_node_dao.go b/internal/db/models/api_node_dao.go index 59ad6f55..a3947fde 100644 --- a/internal/db/models/api_node_dao.go +++ b/internal/db/models/api_node_dao.go @@ -335,6 +335,7 @@ func (this *APINodeDAO) UpdateAPINodeStatus(tx *dbs.Tx, apiNodeId int64, statusJ func (this *APINodeDAO) CountAllLowerVersionNodes(tx *dbs.Tx, version string) (int64, error) { return this.Query(tx). State(APINodeStateEnabled). + Attr("isOn", true). Where("status IS NOT NULL"). Where("(JSON_EXTRACT(status, '$.buildVersionCode') IS NULL OR JSON_EXTRACT(status, '$.buildVersionCode')<:version)"). Param("version", utils.VersionToLong(version)). diff --git a/internal/db/models/authority/authority_node_dao.go b/internal/db/models/authority/authority_node_dao.go index 50e603a6..bf314ea8 100644 --- a/internal/db/models/authority/authority_node_dao.go +++ b/internal/db/models/authority/authority_node_dao.go @@ -210,6 +210,7 @@ func (this *AuthorityNodeDAO) UpdateNodeStatus(tx *dbs.Tx, nodeId int64, nodeSta func (this *AuthorityNodeDAO) CountAllLowerVersionNodes(tx *dbs.Tx, version string) (int64, error) { return this.Query(tx). State(AuthorityNodeStateEnabled). + Attr("isOn", true). Where("status IS NOT NULL"). Where("(JSON_EXTRACT(status, '$.buildVersionCode') IS NULL OR JSON_EXTRACT(status, '$.buildVersionCode')<:version)"). Param("version", utils.VersionToLong(version)). diff --git a/internal/db/models/monitor_node_dao.go b/internal/db/models/monitor_node_dao.go index 3d0f5cdc..6f69f860 100644 --- a/internal/db/models/monitor_node_dao.go +++ b/internal/db/models/monitor_node_dao.go @@ -207,6 +207,7 @@ func (this *MonitorNodeDAO) UpdateNodeStatus(tx *dbs.Tx, nodeId int64, statusJSO func (this *MonitorNodeDAO) CountAllLowerVersionNodes(tx *dbs.Tx, version string) (int64, error) { return this.Query(tx). State(MonitorNodeStateEnabled). + Attr("isOn", true). Where("status IS NOT NULL"). Where("(JSON_EXTRACT(status, '$.buildVersionCode') IS NULL OR JSON_EXTRACT(status, '$.buildVersionCode')<:version)"). Param("version", utils.VersionToLong(version)). diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index 913bf98f..7a2dc776 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -1484,6 +1484,7 @@ func (this *NodeDAO) FindAllNotInstalledNodesWithClusterId(tx *dbs.Tx, clusterId func (this *NodeDAO) CountAllLowerVersionNodesWithClusterId(tx *dbs.Tx, clusterId int64, os string, arch string, version string) (int64, error) { return this.Query(tx). State(NodeStateEnabled). + Attr("isOn", true). Attr("clusterId", clusterId). Where("status IS NOT NULL"). Where("JSON_EXTRACT(status, '$.os')=:os"). @@ -1517,6 +1518,7 @@ func (this *NodeDAO) FindAllLowerVersionNodesWithClusterId(tx *dbs.Tx, clusterId func (this *NodeDAO) CountAllLowerVersionNodes(tx *dbs.Tx, version string) (int64, error) { return this.Query(tx). State(NodeStateEnabled). + Attr("isOn", true). Where("clusterId IN (SELECT id FROM "+SharedNodeClusterDAO.Table+" WHERE state=1)"). Where("status IS NOT NULL"). Where("(JSON_EXTRACT(status, '$.buildVersionCode') IS NULL OR JSON_EXTRACT(status, '$.buildVersionCode')<:version)"). diff --git a/internal/db/models/ns_node_dao.go b/internal/db/models/ns_node_dao.go index 93215acb..278b8ad2 100644 --- a/internal/db/models/ns_node_dao.go +++ b/internal/db/models/ns_node_dao.go @@ -93,6 +93,7 @@ func (this *NSNodeDAO) CountAllLowerVersionNodesWithClusterId(tx *dbs.Tx, cluste return this.Query(tx). State(NSNodeStateEnabled). Attr("clusterId", clusterId). + Attr("isOn", true). Where("status IS NOT NULL"). Where("JSON_EXTRACT(status, '$.os')=:os"). Where("JSON_EXTRACT(status, '$.arch')=:arch"). @@ -161,6 +162,7 @@ func (this *NSNodeDAO) UpdateNodeStatus(tx *dbs.Tx, nodeId int64, nodeStatus *no func (this *NSNodeDAO) CountAllLowerVersionNodes(tx *dbs.Tx, version string) (int64, error) { return this.Query(tx). State(NSNodeStateEnabled). + Attr("isOn", true). Where("clusterId IN (SELECT id FROM "+SharedNSClusterDAO.Table+" WHERE state=1)"). Where("status IS NOT NULL"). Where("(JSON_EXTRACT(status, '$.buildVersionCode') IS NULL OR JSON_EXTRACT(status, '$.buildVersionCode')<:version)"). diff --git a/internal/db/models/user_node_dao.go b/internal/db/models/user_node_dao.go index f4e9cdac..f74f6351 100644 --- a/internal/db/models/user_node_dao.go +++ b/internal/db/models/user_node_dao.go @@ -280,6 +280,7 @@ func (this *UserNodeDAO) UpdateNodeStatus(tx *dbs.Tx, nodeId int64, nodeStatus * func (this *UserNodeDAO) CountAllLowerVersionNodes(tx *dbs.Tx, version string) (int64, error) { return this.Query(tx). State(UserNodeStateEnabled). + Attr("isOn", true). Where("status IS NOT NULL"). Where("(JSON_EXTRACT(status, '$.buildVersionCode') IS NULL OR JSON_EXTRACT(status, '$.buildVersionCode')<:version)"). Param("version", utils.VersionToLong(version)).