Browse Source

fix bug

Former-commit-id: 9c7262a85a
pull/9/head
zhangwei 1 year ago
parent
commit
373a347ea6
3 changed files with 7 additions and 7 deletions
  1. +3
    -3
      api/desc/core/pcm-core.api
  2. +1
    -1
      api/internal/logic/core/resourcecenterinfologic.go
  3. +3
    -3
      api/internal/types/types.go

+ 3
- 3
api/desc/core/pcm-core.api View File

@@ -18,9 +18,9 @@ type (
} }


ResourceUsage { 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 { ResourceTotal {


+ 1
- 1
api/internal/logic/core/resourcecenterinfologic.go View File

@@ -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 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 return
} }

+ 3
- 3
api/internal/types/types.go View File

@@ -13,9 +13,9 @@ type ResourceCenterInfoResp struct {
} }


type ResourceUsage 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 { type ResourceTotal struct {


Loading…
Cancel
Save