|
|
|
@@ -58,42 +58,30 @@ func GetAllCloudbrainsOverview(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
cloudbrainTypeCount, err := models.GetCloudbrainTypeCount() |
|
|
|
log.Info("cloudbrainTypeCount:", cloudbrainTypeCount) |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not query cloudbrainTypeCount.", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
cloudbrainTpyeDurationSum, err := models.GetCloudbrainTpyeDurationSum() |
|
|
|
log.Info("cloudbrainTpyeDurationSum:", cloudbrainTpyeDurationSum) |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not query cloudbrainTpyeDurationSum.", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
todayCloudbrainCount, err := models.GetTodayCloudbrainCount(beginTime, endTime) |
|
|
|
log.Info("todayCloudbrainCount:", todayCloudbrainCount) |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not query todayCloudbrainCount.", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
todayRunningCount, err := models.GetTodayRunningCount(beginTime, endTime) |
|
|
|
log.Info("todayRunningCount:", todayRunningCount) |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not query todayRunningCount.", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
todayWaitingCount, err := models.GetTodayWaitingCount(beginTime, endTime) |
|
|
|
log.Info("todayWaittingCount:", todayWaitingCount) |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not query todayWaitingCount.", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
todayCompletedCount := todayCloudbrainCount - todayRunningCount - todayWaitingCount |
|
|
|
log.Info("todayCompletedCount:", todayCompletedCount) |
|
|
|
|
|
|
|
creatorCount, err := models.GetCreatorCount() |
|
|
|
if err != nil { |
|
|
|
@@ -139,60 +127,48 @@ func GetOverviewDuration(ctx *context.Context) { |
|
|
|
c2NetDuration := int64(0) |
|
|
|
cDCenterDuration := int64(0) |
|
|
|
|
|
|
|
page := 1 |
|
|
|
pagesize := 10000 |
|
|
|
count := pagesize |
|
|
|
// Each time a maximum of 10000 pieces of data are detected to the memory, batch processing |
|
|
|
for count == pagesize && count != 0 { |
|
|
|
cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
PageSize: pagesize, |
|
|
|
}, |
|
|
|
Type: models.TypeCloudBrainAll, |
|
|
|
BeginTimeUnix: int64(recordBeginTime), |
|
|
|
EndTimeUnix: endTime.Unix(), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("Get cloudbrains failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
models.LoadSpecs4CloudbrainInfo(cloudbrains) |
|
|
|
|
|
|
|
for _, cloudbrain := range cloudbrains { |
|
|
|
cloudbrain = cloudbrainService.UpdateCloudbrainAiCenter(cloudbrain) |
|
|
|
if cloudbrain.Cloudbrain.Spec != nil { |
|
|
|
cardNum = int64(cloudbrain.Cloudbrain.Spec.AccCardsNum) |
|
|
|
} else { |
|
|
|
cardNum = 1 |
|
|
|
} |
|
|
|
if cloudbrain.Cloudbrain.WorkServerNumber >= 1 { |
|
|
|
workServerNumber = int64(cloudbrain.Cloudbrain.WorkServerNumber) |
|
|
|
} else { |
|
|
|
workServerNumber = 1 |
|
|
|
} |
|
|
|
duration := models.ConvertStrToDuration(cloudbrain.TrainJobDuration) |
|
|
|
CardDuration := workServerNumber * int64(cardNum) * duration |
|
|
|
|
|
|
|
if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainOne { |
|
|
|
cloudBrainOneDuration += duration |
|
|
|
cloudBrainOneCardDuSum += CardDuration |
|
|
|
} else if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainTwo { |
|
|
|
cloudBrainTwoDuration += duration |
|
|
|
cloudBrainTwoCardDuSum += CardDuration |
|
|
|
} else if cloudbrain.Cloudbrain.Type == models.TypeC2Net { |
|
|
|
c2NetDuration += duration |
|
|
|
c2NetCardDuSum += CardDuration |
|
|
|
} else if cloudbrain.Cloudbrain.Type == models.TypeCDCenter { |
|
|
|
cDCenterDuration += duration |
|
|
|
cDNetCardDuSum += CardDuration |
|
|
|
} |
|
|
|
cloudbrains, _, err := models.CloudbrainAllKanBan(&models.CloudbrainsOptions{ |
|
|
|
Type: models.TypeCloudBrainAll, |
|
|
|
BeginTimeUnix: int64(recordBeginTime), |
|
|
|
EndTimeUnix: endTime.Unix(), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("Get cloudbrains failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
models.LoadSpecs4CloudbrainInfo(cloudbrains) |
|
|
|
|
|
|
|
durationAllSum += duration |
|
|
|
cardDuSum += CardDuration |
|
|
|
for _, cloudbrain := range cloudbrains { |
|
|
|
cloudbrain = cloudbrainService.UpdateCloudbrainAiCenter(cloudbrain) |
|
|
|
if cloudbrain.Cloudbrain.Spec != nil { |
|
|
|
cardNum = int64(cloudbrain.Cloudbrain.Spec.AccCardsNum) |
|
|
|
} else { |
|
|
|
cardNum = 1 |
|
|
|
} |
|
|
|
count = len(cloudbrains) |
|
|
|
page += 1 |
|
|
|
if cloudbrain.Cloudbrain.WorkServerNumber >= 1 { |
|
|
|
workServerNumber = int64(cloudbrain.Cloudbrain.WorkServerNumber) |
|
|
|
} else { |
|
|
|
workServerNumber = 1 |
|
|
|
} |
|
|
|
duration := models.ConvertStrToDuration(cloudbrain.TrainJobDuration) |
|
|
|
CardDuration := workServerNumber * int64(cardNum) * duration |
|
|
|
|
|
|
|
if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainOne { |
|
|
|
cloudBrainOneDuration += duration |
|
|
|
cloudBrainOneCardDuSum += CardDuration |
|
|
|
} else if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainTwo { |
|
|
|
cloudBrainTwoDuration += duration |
|
|
|
cloudBrainTwoCardDuSum += CardDuration |
|
|
|
} else if cloudbrain.Cloudbrain.Type == models.TypeC2Net { |
|
|
|
c2NetDuration += duration |
|
|
|
c2NetCardDuSum += CardDuration |
|
|
|
} else if cloudbrain.Cloudbrain.Type == models.TypeCDCenter { |
|
|
|
cDCenterDuration += duration |
|
|
|
cDNetCardDuSum += CardDuration |
|
|
|
} |
|
|
|
|
|
|
|
durationAllSum += duration |
|
|
|
cardDuSum += CardDuration |
|
|
|
} |
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"cloudBrainOneCardDuSum": cloudBrainOneCardDuSum, |
|
|
|
|