Browse Source

fix-kanban

tags/v1.22.11.2^2^2
liuzx 3 years ago
parent
commit
34f15799a1
5 changed files with 19 additions and 15 deletions
  1. +2
    -2
      routers/admin/cloudbrains.go
  2. +7
    -7
      routers/api/v1/repo/cloudbrain_dashboard.go
  3. +8
    -4
      routers/repo/cloudbrain_statistic.go
  4. +1
    -1
      routers/repo/grampus.go
  5. +1
    -1
      routers/user/home.go

+ 2
- 2
routers/admin/cloudbrains.go View File

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


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

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


+ 8
- 4
routers/repo/cloudbrain_statistic.go View File

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


+ 1
- 1
routers/repo/grampus.go View File

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


+ 1
- 1
routers/user/home.go View File

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


Loading…
Cancel
Save