Browse Source

update

tags/v1.22.11.1^2
liuzx 3 years ago
parent
commit
6e65b7144d
1 changed files with 16 additions and 7 deletions
  1. +16
    -7
      routers/api/v1/repo/cloudbrain_dashboard.go

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

@@ -1728,16 +1728,18 @@ func getDurationStatistic(beginTime time.Time, endTime time.Time) (models.Durati
return OpenIDurationRate, C2NetDurationRate, 0
}
for _, v := range ResourceAiCenterRes {
if v.AiCenterCode != models.AICenterOfCloudBrainOne && v.AiCenterCode != models.AICenterOfCloudBrainTwo {
// if v.AiCenterCode != models.AICenterOfCloudBrainTwo {
if _, ok := C2NetUsageDuration[v.AiCenterName]; !ok {
C2NetUsageDuration[v.AiCenterName] = 0
}
// }
} else {
// if v.AiCenterCode != models.AICenterOfCloudBrainOne && v.AiCenterCode != models.AICenterOfCloudBrainTwo {
if cutString(v.AiCenterCode, 4) == cutString(models.AICenterOfCloudBrainOne, 4) {
if _, ok := OpenIUsageDuration[v.AiCenterName]; !ok {
OpenIUsageDuration[v.AiCenterName] = 0
}
if _, ok := OpenITotalDuration[v.AiCenterName]; !ok {
OpenITotalDuration[v.AiCenterName] = 0
}
} else {
if _, ok := C2NetUsageDuration[v.AiCenterName]; !ok {
C2NetUsageDuration[v.AiCenterName] = 0
}
}
}
totalCanUse := float32(0)
@@ -1773,6 +1775,13 @@ func getDurationStatistic(beginTime time.Time, endTime time.Time) (models.Durati
return OpenIDurationRate, C2NetDurationRate, totalUsageRate
}

func cutString(str string, lens int) string {
if len(str) < lens {
return str
}
return str[:lens]
}

func getDayCloudbrainDuration(beginTime time.Time, endTime time.Time, aiCenterCode string) ([]models.DateUsageStatistic, int, error) {
now := time.Now()
endTimeTemp := time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 0, 0, 0, 0, now.Location())


Loading…
Cancel
Save