#4589 支持过滤中心

Merged
zouap merged 2 commits from fix-4304 into V20230808 9 months ago
  1. +11
    -3
      modules/setting/screen_map.go
  2. +17
    -1
      routers/api/v1/repo/cloudbrain_dashboard.go

+ 11
- 3
modules/setting/screen_map.go View File

@@ -1,9 +1,12 @@
package setting

import "strings"

var ScreenMap = struct {
ShowData bool
MinValue int
MaxValue int
ShowData bool
MinValue int
MaxValue int
ExcludeCenter []string
}{}

var IPInfo = struct {
@@ -16,6 +19,11 @@ func NewScreenMapConfig() {
ScreenMap.ShowData = sec.Key("ShowData").MustBool(false)
ScreenMap.MinValue = sec.Key("MinValue").MustInt(130)
ScreenMap.MaxValue = sec.Key("MaxValue").MustInt(190)
ScreenMap.ExcludeCenter = []string{}
excludeCenterStr := sec.Key("ExcludeCenter").MustString("")
if excludeCenterStr != "" {
ScreenMap.ExcludeCenter = strings.Split(excludeCenterStr, ",")
}

sec = Cfg.Section("IPInfo")



+ 17
- 1
routers/api/v1/repo/cloudbrain_dashboard.go View File

@@ -211,14 +211,21 @@ func GetCloubrainOverviewGroupByAiCenter(ctx *context.Context) {

if setting.ScreenMap.ShowData || ctx.IsUserSiteAdmin() {

var cloudbrainCardTimeAndCountFilterArray = make([]map[string]string, 0)

for _, cloudbrainCardTimeAndCountMap := range cloudbrainCardTimeAndCountArray {
centerId := cloudbrainCardTimeAndCountMap["ai_center"]
centerShow := cloudbrainService.GetAiCenterShowByAiCenterId(centerId, ctx)
cloudbrainCardTimeAndCountMap["ai_center"] = centerShow

if len(setting.ScreenMap.ExcludeCenter) > 0 && isExcludeCenter(centerId) {
continue

}
cloudbrainCardTimeAndCountFilterArray = append(cloudbrainCardTimeAndCountFilterArray, cloudbrainCardTimeAndCountMap)
}
ctx.JSON(http.StatusOK, map[string]interface{}{
"cardAndJobCount": cloudbrainCardTimeAndCountArray,
"cardAndJobCount": cloudbrainCardTimeAndCountFilterArray,
"locationInfo": aiCenterLocationInfos,
})
return
@@ -232,6 +239,15 @@ func GetCloubrainOverviewGroupByAiCenter(ctx *context.Context) {

}

func isExcludeCenter(id string) bool {
for _, centerId := range setting.ScreenMap.ExcludeCenter {
if id == centerId {
return true
}
}
return false
}

func getAiCenterSize(name string, timeMap map[string]int64, MaxCardTime int64, MinCardTime int64) int {
cardTime, _ := timeMap[name]
if cardTime == 0 {


Loading…
Cancel
Save