From 373a347ea65fad8abd9e5733ea34201433b31301 Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Wed, 24 Jan 2024 09:53:05 +0800 Subject: [PATCH] fix bug Former-commit-id: 9c7262a85ad9248a248fd231adcdcb76bd7283e6 --- api/desc/core/pcm-core.api | 6 +++--- api/internal/logic/core/resourcecenterinfologic.go | 2 +- api/internal/types/types.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index 128c9c5c..bd1905c9 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -18,9 +18,9 @@ type ( } ResourceUsage { - cpu int64 `json:"cpu"` - memory int64 `json:"memory"` - storage int64 `json:"storage"` + cpu float64 `json:"cpu"` + memory float64 `json:"memory"` + storage float64 `json:"storage"` } ResourceTotal { diff --git a/api/internal/logic/core/resourcecenterinfologic.go b/api/internal/logic/core/resourcecenterinfologic.go index ff5682b1..e37b4b65 100644 --- a/api/internal/logic/core/resourcecenterinfologic.go +++ b/api/internal/logic/core/resourcecenterinfologic.go @@ -32,6 +32,6 @@ func (l *ResourceCenterInfoLogic) ResourceCenterInfo(req *types.ResourceCenterIn l.svcCtx.DbEngin.Raw("select SUm(cpu_total) as cpu,sum(mem_total) as memory,SUM(disk_total) as storage FROM sc_node_avail_info where participant_id = ? GROUP BY created_time ORDER BY created_time desc LIMIT 1", req.ParticipantId).Scan(&resp.ResourceTotal) - l.svcCtx.DbEngin.Raw("select IFNULL(SUM(cpu_usable)/COUNT(*),0)as cpu,IFNULL(sum(mem_avail)/SUM(mem_total),0) as memory,IFNULL(sum(disk_avail)/SUM(disk_total),0) as storage FROM sc_node_avail_info where participant_id = ? GROUP BY created_time ORDER BY created_time desc LIMIT 1", req.ParticipantId).Scan(&resp.ResourceUsage) + l.svcCtx.DbEngin.Raw("select IFNULL(SUM(cpu_usable)/COUNT(*),0)as cpu,IFNULL(sum(mem_avail)/SUM(mem_total),0) as memory,IFNULL(sum(disk_avail)/SUM(disk_total),0) as storage FROM sc_node_avail_info where cpu_total != 0 and participant_id = ? GROUP BY created_time ORDER BY created_time desc LIMIT 1", req.ParticipantId).Scan(&resp.ResourceUsage) return } diff --git a/api/internal/types/types.go b/api/internal/types/types.go index d6e4382a..2e52c925 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -13,9 +13,9 @@ type ResourceCenterInfoResp struct { } type ResourceUsage struct { - Cpu int64 `json:"cpu"` - Memory int64 `json:"memory"` - Storage int64 `json:"storage"` + Cpu float64 `json:"cpu"` + Memory float64 `json:"memory"` + Storage float64 `json:"storage"` } type ResourceTotal struct {