Skip to content

Commit

Permalink
fix 123
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq committed Sep 9, 2024
1 parent 2f961f8 commit 859e6ea
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 859e6ea

Please sign in to comment.