From 34f15799a11d860ee69a84792f3ce30815bba6ce Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 10 Nov 2022 17:01:17 +0800 Subject: [PATCH] fix-kanban --- routers/admin/cloudbrains.go | 4 ++-- routers/api/v1/repo/cloudbrain_dashboard.go | 14 +++++++------- routers/repo/cloudbrain_statistic.go | 12 ++++++++---- routers/repo/grampus.go | 2 +- routers/user/home.go | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index 8ca8344a8..91685251b 100755 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -97,7 +97,7 @@ func CloudBrains(ctx *context.Context) { for i, task := range ciTasks { ciTasks[i] = cloudbrainService.UpdateCloudbrainAiCenter(ciTasks[i]) - ciTasks[i].Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(ciTasks[i].Cloudbrain.AiCenter) + ciTasks[i].Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(ciTasks[i].Cloudbrain.AiCenter, ctx.Language()) ciTasks[i].CanDebug = true ciTasks[i].CanDel = true ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource @@ -190,7 +190,7 @@ func DownloadCloudBrains(ctx *context.Context) { models.LoadSpecs4CloudbrainInfo(pageRecords) for _, record := range pageRecords { record = cloudbrainService.UpdateCloudbrainAiCenter(record) - record.Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(record.Cloudbrain.AiCenter) + record.Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(record.Cloudbrain.AiCenter, ctx.Language()) for k, v := range allValues(row, record, ctx) { f.SetCellValue(cloudBrain, k, v) } diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index 1eb772b42..f1ae2b9ee 100755 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -799,7 +799,7 @@ func GetCloudbrainsDetailData(ctx *context.Context) { taskDetail.Type = ciTasks[i].Cloudbrain.Type taskDetail.UserName = ciTasks[i].User.Name taskDetail.RepoID = ciTasks[i].RepoID - taskDetail.AiCenter = repo.GetAiCenterNameByCode(task.Cloudbrain.AiCenter) + taskDetail.AiCenter = repo.GetAiCenterNameByCode(task.Cloudbrain.AiCenter, ctx.Language()) if ciTasks[i].Repo != nil { taskDetail.RepoName = ciTasks[i].Repo.OwnerName + "/" + ciTasks[i].Repo.Name taskDetail.RepoAlias = ciTasks[i].Repo.OwnerName + "/" + ciTasks[i].Repo.Alias @@ -1249,7 +1249,7 @@ func DownloadCloudBrainBoard(ctx *context.Context) { models.LoadSpecs4CloudbrainInfo(pageRecords) for _, record := range pageRecords { record = cloudbrainService.UpdateCloudbrainAiCenter(record) - record.Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(record.Cloudbrain.AiCenter) + record.Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(record.Cloudbrain.AiCenter, ctx.Language()) for k, v := range allCloudbrainValues(row, record, ctx) { f.SetCellValue(cloudBrain, k, v) } @@ -1452,7 +1452,7 @@ func GetCloudbrainResourceOverview(ctx *context.Context) { C2NetResourceDetail := []models.ResourceDetail{} for _, resourceQueue := range resourceQueues { if resourceQueue.Cluster == models.OpenICluster { - aiCenterName := repo.GetAiCenterNameByCode(resourceQueue.AiCenterCode) + aiCenterName := repo.GetAiCenterNameByCode(resourceQueue.AiCenterCode, ctx.Language()) var resourceDetail models.ResourceDetail resourceDetail.QueueCode = resourceQueue.QueueCode resourceDetail.Cluster = resourceQueue.Cluster @@ -1465,7 +1465,7 @@ func GetCloudbrainResourceOverview(ctx *context.Context) { OpenIResourceDetail = append(OpenIResourceDetail, resourceDetail) } if resourceQueue.Cluster == models.C2NetCluster { - aiCenterName := repo.GetAiCenterNameByCode(resourceQueue.AiCenterCode) + aiCenterName := repo.GetAiCenterNameByCode(resourceQueue.AiCenterCode, ctx.Language()) var resourceDetail models.ResourceDetail resourceDetail.QueueCode = resourceQueue.QueueCode resourceDetail.Cluster = resourceQueue.Cluster @@ -1685,7 +1685,7 @@ func getDurationStatistic(beginTime time.Time, endTime time.Time) (models.Durati return OpenIDurationRate, C2NetDurationRate, 0 } for _, cloudbrainStatistic := range cardDurationStatistics { - aiCenterName := cloudbrainStatistic.AiCenterCode + "/" + repo.GetAiCenterNameByCode(cloudbrainStatistic.AiCenterCode) + aiCenterName := cloudbrainStatistic.AiCenterCode + "/" + repo.GetAiCenterNameByCode(cloudbrainStatistic.AiCenterCode, "zh-CN") if cloudbrainStatistic.Cluster == models.OpenICluster { if _, ok := OpenITotalDuration[aiCenterName]; !ok { OpenITotalDuration[aiCenterName] = cloudbrainStatistic.CardsTotalDuration @@ -1717,7 +1717,7 @@ func getDurationStatistic(beginTime time.Time, endTime time.Time) (models.Durati return OpenIDurationRate, C2NetDurationRate, 0 } for _, v := range ResourceAiCenterRes { - aiCenterName := v.AiCenterCode + "/" + repo.GetAiCenterNameByCode(v.AiCenterCode) + aiCenterName := v.AiCenterCode + "/" + repo.GetAiCenterNameByCode(v.AiCenterCode, "zh-CN") if cutString(v.AiCenterCode, 4) == cutString(models.AICenterOfCloudBrainOne, 4) { if _, ok := OpenIUsageDuration[aiCenterName]; !ok { OpenIUsageDuration[aiCenterName] = 0 @@ -1877,7 +1877,7 @@ func GetResourceQueues(ctx *context.Context) { aiCenterCodeMap := make(map[string]string) for _, resourceQueue := range resourceQueues { if _, ok := aiCenterCodeMap[resourceQueue.AiCenterCode]; !ok { - resourceQueue.AiCenterName = repo.GetAiCenterNameByCode(resourceQueue.AiCenterCode) + resourceQueue.AiCenterName = repo.GetAiCenterNameByCode(resourceQueue.AiCenterCode, ctx.Language()) aiCenterCodeMap[resourceQueue.AiCenterCode] = resourceQueue.AiCenterCode Resource = append(Resource, resourceQueue) } diff --git a/routers/repo/cloudbrain_statistic.go b/routers/repo/cloudbrain_statistic.go index 067920d56..547b78f06 100644 --- a/routers/repo/cloudbrain_statistic.go +++ b/routers/repo/cloudbrain_statistic.go @@ -86,7 +86,7 @@ func summaryDurationStat(statisticTime time.Time) int64 { DayTime: dayTime, HourTime: hourTime, Cluster: cloudbrainTable.Cluster, - AiCenterName: GetAiCenterNameByCode(centerCode), + AiCenterName: GetAiCenterNameByCode(centerCode, "zh-CN"), AiCenterCode: centerCode, AccCardType: cardType, ComputeResource: cloudbrainTable.ComputeResource, @@ -113,7 +113,7 @@ func summaryDurationStat(statisticTime time.Time) int64 { DayTime: dayTime, HourTime: hourTime, Cluster: strings.Split(key, "/")[0], - AiCenterName: GetAiCenterNameByCode(strings.Split(key, "/")[1]), + AiCenterName: GetAiCenterNameByCode(strings.Split(key, "/")[1], "zh-CN"), AiCenterCode: strings.Split(key, "/")[1], AccCardType: strings.Split(key, "/")[2], ComputeResource: strings.Split(key, "/")[3], @@ -132,11 +132,15 @@ func summaryDurationStat(statisticTime time.Time) int64 { return count } -func GetAiCenterNameByCode(centerCode string) string { +func GetAiCenterNameByCode(centerCode string, language string) string { var aiCenterName string aiCenterInfo := cloudbrainService.GetAiCenterInfoByCenterCode(centerCode) if aiCenterInfo != nil { - aiCenterName = aiCenterInfo.Content + if language == "zh-CN" { + aiCenterName = aiCenterInfo.Content + } else { + aiCenterName = aiCenterInfo.ContentEN + } } else { aiCenterName = centerCode } diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index ae4ad8a76..268830dc8 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -1123,7 +1123,7 @@ func HandleTaskWithAiCenter(ctx *context.Context) { log.Error("GetJob failed:" + err.Error()) continue } - if result != nil { + if len(result.JobInfo.Tasks) != 0 { if len(result.JobInfo.Tasks[0].CenterID) == 1 && len(result.JobInfo.Tasks[0].CenterName) == 1 { task.AiCenter = result.JobInfo.Tasks[0].CenterID[0] + "+" + result.JobInfo.Tasks[0].CenterName[0] } diff --git a/routers/user/home.go b/routers/user/home.go index 4d6a96204..62b0357ad 100755 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -840,7 +840,7 @@ func Cloudbrains(ctx *context.Context) { models.LoadSpecs4CloudbrainInfo(ciTasks) for i, _ := range ciTasks { ciTasks[i] = cloudbrainService.UpdateCloudbrainAiCenter(ciTasks[i]) - ciTasks[i].Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(ciTasks[i].Cloudbrain.AiCenter) + ciTasks[i].Cloudbrain.AiCenter = repo.GetAiCenterNameByCode(ciTasks[i].Cloudbrain.AiCenter, ctx.Language()) ciTasks[i].CanDebug = true ciTasks[i].CanDel = true ciTasks[i].Cloudbrain.ComputeResource = ciTasks[i].ComputeResource