From 859e6ea5ccb979b36f43229b4455b03f6c7bad5a Mon Sep 17 00:00:00 2001 From: make123 Date: Mon, 9 Sep 2024 19:09:21 +0800 Subject: [PATCH] fix 123 --- .../controller/statistic/statistic.go | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/dbm-services/common/db-resource/internal/controller/statistic/statistic.go b/dbm-services/common/db-resource/internal/controller/statistic/statistic.go index c7d7ffdbf7..5a54768523 100644 --- a/dbm-services/common/db-resource/internal/controller/statistic/statistic.go +++ b/dbm-services/common/db-resource/internal/controller/statistic/statistic.go @@ -302,17 +302,16 @@ type GroupBySpecResult struct { SpecId int `json:"spec_id"` SpecName string `json:"spec_name"` SpecMachineType string `json:"spec_machine_type"` + SpecClusterType string `json:"spec_cluster_type"` Count int `json:"count"` SubZoneDetail map[string]int `json:"sub_zone_detail"` } func groupByDbmSpec(rpList []model.TbRpDetail, specList []dbmapi.DbmSpec) (result []GroupBySpecResult, err error) { result = []GroupBySpecResult{} - specNameMap := make(map[int]string) - specMachineTypeMap := make(map[int]string) + specMap := make(map[int]dbmapi.DbmSpec) for _, spec := range specList { - specNameMap[spec.SpecId] = spec.SpecName - specMachineTypeMap[spec.SpecId] = spec.SpecMachineType + specMap[spec.SpecId] = spec } specMatchrelationMap := rsMatchSpecs(rpList, specList) groupMap := make(map[string][]model.TbRpDetail) @@ -342,20 +341,18 @@ func groupByDbmSpec(rpList []model.TbRpDetail, specList []dbmapi.DbmSpec) (resul logger.Error("parse group key failed %s", err.Error) continue } - specName, ok := specNameMap[specId] + spec, ok := specMap[specId] if !ok { - specName = "" - } - specMachineType, ok := specMachineTypeMap[specId] - if !ok { - specMachineType = "" + spec = dbmapi.DbmSpec{} } + cityCountMap[city] += len(grs) cityMap[city] = append(cityMap[city], GroupBySpecResult{ DedicatedBiz: dedicatedBiz, SpecId: specId, - SpecName: specName, - SpecMachineType: specMachineType, + SpecName: spec.SpecName, + SpecMachineType: spec.SpecMachineType, + SpecClusterType: spec.SpecClusterType, City: city, Count: len(grs), SubZoneDetail: subZonegroupMap[groupKey],