Browse Source

fix-kanban

tags/v1.22.11.2^2^2
liuzx 3 years ago
parent
commit
7f08370774
3 changed files with 17 additions and 2 deletions
  1. +9
    -0
      models/cloudbrain_static.go
  2. +1
    -1
      routers/api/v1/repo/cloudbrain_dashboard.go
  3. +7
    -1
      routers/repo/cloudbrain_statistic.go

+ 9
- 0
models/cloudbrain_static.go View File

@@ -375,3 +375,12 @@ func GetDurationRecordBeginTime() ([]*CloudbrainDurationStatistic, error) {
}
return CloudbrainDurationStatistics, nil
}
func DeleteCloudbrainDurationStatistic() error {
sess := xStatistic.NewSession()
defer sess.Close()
if _, err := sess.Exec("TRUNCATE TABLE cloudbrain_duration_statistic"); err != nil {
log.Info("TRUNCATE cloudbrain_duration_statistic error.")
return err
}
return nil
}

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

@@ -1744,7 +1744,7 @@ func getDurationStatistic(beginTime time.Time, endTime time.Time) (models.Durati
for _, v := range OpenITotalDuration {
totalCanUse += float64(v)
}
for _, v := range OpenIUsageRate {
for _, v := range OpenIUsageDuration {
totalUse += float64(v)
}
if totalCanUse == 0 || totalUse == 0 {


+ 7
- 1
routers/repo/cloudbrain_statistic.go View File

@@ -70,7 +70,11 @@ func summaryDurationStat(statisticTime time.Time) int64 {
}
cardsTotalDurationMap := make(map[string]int)
for _, resourceQueue := range resourceQueues {
cardsTotalDurationMap[resourceQueue.Cluster+"/"+resourceQueue.AiCenterCode+"/"+resourceQueue.AccCardType+"/"+resourceQueue.ComputeResource] = resourceQueue.CardsTotalNum * 1 * 60 * 60
if _, ok := cardsTotalDurationMap[resourceQueue.Cluster+"/"+resourceQueue.AiCenterCode+"/"+resourceQueue.AccCardType+"/"+resourceQueue.ComputeResource]; !ok {
cardsTotalDurationMap[resourceQueue.Cluster+"/"+resourceQueue.AiCenterCode+"/"+resourceQueue.AccCardType+"/"+resourceQueue.ComputeResource] = resourceQueue.CardsTotalNum * 1 * 60 * 60
} else {
cardsTotalDurationMap[resourceQueue.Cluster+"/"+resourceQueue.AiCenterCode+"/"+resourceQueue.AccCardType+"/"+resourceQueue.ComputeResource] += resourceQueue.CardsTotalNum * 1 * 60 * 60
}
}

for centerCode, CardTypes := range cloudBrainCenterCodeAndCardTypeInfo {
@@ -224,9 +228,11 @@ func getcloudBrainCenterCodeAndCardTypeInfo(ciTasks []*models.CloudbrainInfo, be
}

func CloudbrainUpdateHistoryData(ctx *context.Context) {
err := models.DeleteCloudbrainDurationStatistic()
count := UpdateDurationStatisticHistoryData()
ctx.JSON(http.StatusOK, map[string]interface{}{
"message": 0,
"count": count,
"err": err,
})
}

Loading…
Cancel
Save