Browse Source

update

tags/v1.22.6.1^2
liuzx 3 years ago
parent
commit
dc20fcdbe3
4 changed files with 219 additions and 69 deletions
  1. +86
    -12
      models/cloudbrain_static.go
  2. +1
    -1
      routers/api/v1/api.go
  3. +112
    -42
      routers/api/v1/repo/cloudbrain_dashboard.go
  4. +20
    -14
      routers/repo/cloudbrain_statistic.go

+ 86
- 12
models/cloudbrain_static.go View File

@@ -52,6 +52,14 @@ func GetJobRunningCount(beginTime time.Time, endTime time.Time) (int64, error) {

return x.SQL(countSql).Count()
}
func GetJobStoppedCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
" and status ='" + string(JobStopped) + "'"

return x.SQL(countSql).Count()
}
func GetJobSucceededCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
@@ -60,6 +68,14 @@ func GetJobSucceededCount(beginTime time.Time, endTime time.Time) (int64, error)

return x.SQL(countSql).Count()
}
func GetJobFailedCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
" and status ='" + string(JobFailed) + "'"

return x.SQL(countSql).Count()
}

// func GetWaitingCount(beginTime time.Time, endTime time.Time) (int64, error) {
// countSql := "SELECT distinct count(*) FROM " +
@@ -70,7 +86,7 @@ func GetJobSucceededCount(beginTime time.Time, endTime time.Time) (int64, error)
// return x.SQL(countSql).Count()
// }

func GetDebugOneCount(beginTime time.Time, endTime time.Time) (int64, error) {
func GetDebugOnePeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
@@ -79,7 +95,7 @@ func GetDebugOneCount(beginTime time.Time, endTime time.Time) (int64, error) {

return x.SQL(countSql).Count()
}
func GetDebugOneDuration(beginTime time.Time, endTime time.Time) (int64, error) {
func GetDebugOnePeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And job_type = ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), JobTypeDebug, TypeCloudBrainOne).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
@@ -88,7 +104,7 @@ func GetDebugOneDuration(beginTime time.Time, endTime time.Time) (int64, error)
return total, nil
}

func GetTrainOneCount(beginTime time.Time, endTime time.Time) (int64, error) {
func GetTrainOnePeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
@@ -97,7 +113,7 @@ func GetTrainOneCount(beginTime time.Time, endTime time.Time) (int64, error) {

return x.SQL(countSql).Count()
}
func GetTrainOneDuration(beginTime time.Time, endTime time.Time) (int64, error) {
func GetTrainOnePeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And job_type = ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), JobTypeTrain, TypeCloudBrainOne).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
@@ -106,7 +122,7 @@ func GetTrainOneDuration(beginTime time.Time, endTime time.Time) (int64, error)
return total, nil
}

func GetBenchmarkOneCount(beginTime time.Time, endTime time.Time) (int64, error) {
func GetBenchmarkOnePeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
@@ -114,7 +130,7 @@ func GetBenchmarkOneCount(beginTime time.Time, endTime time.Time) (int64, error)
" and type='" + strconv.Itoa(TypeCloudBrainOne) + "'"
return x.SQL(countSql).Count()
}
func GetBenchmarkOneDuration(beginTime time.Time, endTime time.Time) (int64, error) {
func GetBenchmarkOnePeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And job_type = ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), JobTypeBenchmark, TypeCloudBrainOne).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
@@ -122,7 +138,7 @@ func GetBenchmarkOneDuration(beginTime time.Time, endTime time.Time) (int64, err

return total, nil
}
func GetDebugTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
func GetDebugTwoPeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
@@ -130,14 +146,14 @@ func GetDebugTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
" and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"
return x.SQL(countSql).Count()
}
func GetDebugTwoDuration(beginTime time.Time, endTime time.Time) (int64, error) {
func GetDebugTwoPeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And job_type = ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), JobTypeDebug, TypeCloudBrainTwo).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
}
return total, nil
}
func GetTrainTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
func GetTrainTwoPeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
@@ -145,14 +161,14 @@ func GetTrainTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
" and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"
return x.SQL(countSql).Count()
}
func GetTrainTwoDuration(beginTime time.Time, endTime time.Time) (int64, error) {
func GetTrainTwoPeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And job_type = ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), JobTypeTrain, TypeCloudBrainTwo).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
}
return total, nil
}
func GetInferenceTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
func GetInferenceTwoPeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
@@ -160,7 +176,7 @@ func GetInferenceTwoCount(beginTime time.Time, endTime time.Time) (int64, error)
" and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"
return x.SQL(countSql).Count()
}
func GetInferenceTwoDuration(beginTime time.Time, endTime time.Time) (int64, error) {
func GetInferenceTwoPeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And job_type = ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), JobTypeInference, TypeCloudBrainTwo).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
@@ -168,6 +184,64 @@ func GetInferenceTwoDuration(beginTime time.Time, endTime time.Time) (int64, err
return total, nil
}

func GetCloudBrainOnePeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
" and type='" + strconv.Itoa(TypeCloudBrainOne) + "'"
return x.SQL(countSql).Count()
}
func GetCloudBrainOnePeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), TypeCloudBrainOne).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
}
return total, nil
}
func GetCloudBrainTwoPeriodCount(beginTime time.Time, endTime time.Time) (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
" and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
" and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"
return x.SQL(countSql).Count()
}
func GetCloudBrainTwoPeriodDuration(beginTime time.Time, endTime time.Time) (int64, error) {
total, err := x.Where("created_unix >= ? And created_unix < ? And type = ? ", strconv.FormatInt(beginTime.Unix(), 10), strconv.FormatInt(endTime.Unix(), 10), TypeCloudBrainTwo).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
}
return total, nil
}

func GetCloudBrainOneCount() (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where type='" + strconv.Itoa(TypeCloudBrainOne) + "'"

return x.SQL(countSql).Count()
}
func GetCloudBrainOneDuration() (int64, error) {
total, err := x.Where("type = ? ", TypeCloudBrainOne).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
}

return total, nil
}
func GetCloudBrainTwoCount() (int64, error) {
countSql := "SELECT count(*) FROM " +
"public.cloudbrain where type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"

return x.SQL(countSql).Count()
}
func GetCloudBrainTwoDuration() (int64, error) {
total, err := x.Where("type = ? ", TypeCloudBrainTwo).SumInt(&Cloudbrain{}, "duration")
if err != nil {
return 0, err
}

return total, nil
}

func DeleteCloudbrainStatisticDaily(date string) error {
sess := xStatistic.NewSession()
defer sess.Close()


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

@@ -563,8 +563,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/downloadAll", repo.DownloadCloudBrainBoard)
m.Group("/cloudbrain", func() {
m.Get("/overview", repo.GetAllCloudbrainsOverview)
m.Get("/trend", repo.GetAllCloudbrainsTrend)
m.Get("/distribution", repo.GetAllCloudbrainsPeriodDistribution)
m.Get("/trend", repo.GetAllCloudbrainsTrend)
})
}, operationReq)



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

@@ -15,15 +15,28 @@ import (
)

type CloudbrainsPeriodData struct {
DebugOneCount int64 `json:"debugOneCount"`
BenchmarkOneCount int64 `json:"benchmarkOneCount"`
TrainOneCount int64 `json:"trainOneCount"`
DebugTwoCount int64 `json:"debugTwoCount"`
TrainTwoCount int64 `json:"trainTwoCount"`
InferenceTwoCount int64 `json:"inferenceTwoCount"`
JobWaitingCount int64 `json:"jobWaitingCount"`
JobRunningCount int64 `json:"jobRunningCount"`
JobSucceededCount int64 `json:"jobRunningCount"`
DebugOnePeriodCount int64 `json:"debugOnePeriodCount"`
BenchmarkOnePeriodCount int64 `json:"benchmarkOnePeriodCount"`
TrainOnePeriodCount int64 `json:"trainOnePeriodCount"`
DebugTwoPeriodCount int64 `json:"debugTwoPeriodCount"`
TrainTwoPeriodCount int64 `json:"trainTwoPeriodCount"`
InferenceTwoPeriodCount int64 `json:"inferenceTwoPeriodCount"`
JobWaitingPeriodCount int64 `json:"jobWaitingPeriodCount"`
JobRunningPeriodCount int64 `json:"jobRunningPeriodCount"`
JobSucceededPeriodCount int64 `json:"jobRunningPeriodCount"`
CloudBrainOnePeriodCount int64 `json:"cloudBrainOnePeriodCount"`
CloudBrainTwoPeriodCount int64 `json:"cloudBrainTwoPeriodCount"`
}
type CloudbrainsOverviewData struct {
JobWaitingCount int64 `json:"jobWaitingCount"`
JobRunningCount int64 `json:"jobRunningCount"`
JobStoppedCount int64 `json:"jobStoppedCount"`
JobSucceededCount int64 `json:"jobSucceededCount"`
JobFailedCount int64 `json:"jobFailedCount"`
CloudBrainOneCount int64 `json:"cloudBrainOneCount"`
CloudBrainTwoCount int64 `json:"cloudBrainTwoCount"`
CloudBrainOneDuration int64 `json:"cloudBrainOneDuration"`
CloudBrainTwoDuration int64 `json:"cloudBrainTwoDuration"`
}
type TimeCloudbrainsNum struct {
TimeCloudbrainNum []DateCloudbrainNum `json:"dateCloudbrainNum"`
@@ -46,26 +59,68 @@ func GetAllCloudbrainsOverview(ctx *context.Context) {
//today overview
beginTime := now.AddDate(0, 0, 0)
beginTime = time.Date(beginTime.Year(), beginTime.Month(), beginTime.Day(), 0, 0, 0, 0, now.Location())
log.Info("beginTime:", beginTime)
endTime := now
log.Info("endTime:", endTime)
jobWaitingCount, err := models.GetJobWaitingCount(beginTime, endTime)
if err != nil {
log.Error("Can not query jobWaitingCount.", err)
return
}
jobRunningCount, err := models.GetJobRunningCount(beginTime, endTime)
if err != nil {
log.Error("Can not query jobRunningCount.", err)
return
}
jobStoppedCount, err := models.GetJobStoppedCount(beginTime, endTime)
if err != nil {
log.Error("Can not query jobStoppedCount.", err)
return
}
jobSucceededCount, err := models.GetJobSucceededCount(beginTime, endTime)
if err != nil {
log.Error("Can not query jobSucceededCount.", err)
return
}
cloudbrainsPeriodData := CloudbrainsPeriodData{
JobWaitingCount: jobWaitingCount,
JobRunningCount: jobRunningCount,
JobSucceededCount: jobSucceededCount,
jobFailedCount, err := models.GetJobFailedCount(beginTime, endTime)
if err != nil {
log.Error("Can not query jobFailedCount.", err)
return
}
cloudBrainOneCount, err := models.GetCloudBrainOneCount()
if err != nil {
log.Error("Can not query cloudBrainOneCount.", err)
return
}
cloudBrainOneDuration, err := models.GetCloudBrainOneDuration()
if err != nil {
log.Error("Can not query cloudBrainOneDuration.", err)
return
}
cloudBrainTwoCount, err := models.GetCloudBrainTwoCount()
if err != nil {
log.Error("Can not query cloudBrainTwoCount.", err)
return
}
cloudBrainTwoDuration, err := models.GetCloudBrainTwoDuration()
if err != nil {
log.Error("Can not query cloudBrainTwoDuration.", err)
return
}

ctx.JSON(http.StatusOK, cloudbrainsPeriodData)
CloudbrainsOverviewData := CloudbrainsOverviewData{
JobWaitingCount: jobWaitingCount,
JobRunningCount: jobRunningCount,
JobStoppedCount: jobStoppedCount,
JobSucceededCount: jobSucceededCount,
JobFailedCount: jobFailedCount,
CloudBrainOneCount: cloudBrainOneCount,
CloudBrainTwoCount: cloudBrainTwoCount,
CloudBrainOneDuration: cloudBrainOneDuration,
CloudBrainTwoDuration: cloudBrainTwoDuration,
}

ctx.JSON(http.StatusOK, CloudbrainsOverviewData)
}

func GetAllCloudbrainsTrend(ctx *context.Context) {
@@ -237,95 +292,110 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) {
ctx.Error(http.StatusBadRequest, ctx.Tr("repo.parameter_is_wrong"))
return
}
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
}
pageSize := ctx.QueryInt("pagesize")
if pageSize <= 0 {
pageSize = DEFAULT_PAGE_SIZE
}
debugOneCount, err := models.GetDebugOneCount(beginTime, endTime)
debugOnePeriodCount, err := models.GetDebugOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query debugOneCount.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("debugOneCount_get_error"))
return
}
benchmarkOneCount, err := models.GetBenchmarkOneCount(beginTime, endTime)
benchmarkOnePeriodCount, err := models.GetBenchmarkOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query benchmarkCount.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("benchmarkOneCount_get_error"))
return
}
trainOneCount, err := models.GetTrainOneCount(beginTime, endTime)
trainOnePeriodCount, err := models.GetTrainOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query trainOneCount.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("trainOneCount_get_error"))
return
}
debugTwoCount, err := models.GetDebugTwoCount(beginTime, endTime)
debugTwoPeriodCount, err := models.GetDebugTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query debugTwoCount.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("debugTwoCount_get_error"))
return
}
trainTwoCount, err := models.GetTrainTwoCount(beginTime, endTime)
trainTwoPeriodCount, err := models.GetTrainTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query DebugOneTotal count.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("total_count_get_error"))
return
}
inferenceTwoCount, err := models.GetInferenceTwoCount(beginTime, endTime)
inferenceTwoPeriodCount, err := models.GetInferenceTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query inferenceTwoCount.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("inferenceTwoCount_get_error"))
return
}
cloudBrainOnePeriodCount, err := models.GetCloudBrainOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query cloudBrainOnePeriodCount.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("cloudBrainOnePeriodCount_get_error"))
return
}
cloudBrainTwoPeriodCount, err := models.GetCloudBrainTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query cloudBrainTwoPeriodCount.", err)
ctx.Error(http.StatusBadRequest, ctx.Tr("cloudBrainTwoPeriodCount_get_error"))
return
}

cloudbrainsPeriodData := CloudbrainsPeriodData{
DebugOneCount: debugOneCount,
BenchmarkOneCount: benchmarkOneCount,
TrainOneCount: trainOneCount,
DebugTwoCount: debugTwoCount,
TrainTwoCount: trainTwoCount,
InferenceTwoCount: inferenceTwoCount,
DebugOnePeriodCount: debugOnePeriodCount,
BenchmarkOnePeriodCount: benchmarkOnePeriodCount,
TrainOnePeriodCount: trainOnePeriodCount,
DebugTwoPeriodCount: debugTwoPeriodCount,
TrainTwoPeriodCount: trainTwoPeriodCount,
InferenceTwoPeriodCount: inferenceTwoPeriodCount,
CloudBrainOnePeriodCount: cloudBrainOnePeriodCount,
CloudBrainTwoPeriodCount: cloudBrainTwoPeriodCount,
}

ctx.JSON(http.StatusOK, cloudbrainsPeriodData)
}

func getCloudbrainCount(beginTime time.Time, endTime time.Time) (int64, int64, int64, int64, int64, int64, int64, int64, int64, error) {
debugOneCount, err := models.GetDebugOneCount(beginTime, endTime)
debugOneCount, err := models.GetDebugOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query debugOneCount.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
benchmarkOneCount, err := models.GetBenchmarkOneCount(beginTime, endTime)
benchmarkOneCount, err := models.GetBenchmarkOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query benchmarkCount.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
trainOneCount, err := models.GetTrainOneCount(beginTime, endTime)
trainOneCount, err := models.GetTrainOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query trainOneCount.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
debugTwoCount, err := models.GetDebugTwoCount(beginTime, endTime)
debugTwoCount, err := models.GetDebugTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query debugTwoCount.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
trainTwoCount, err := models.GetTrainTwoCount(beginTime, endTime)
trainTwoCount, err := models.GetTrainTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query DebugOneTotal count.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
inferenceTwoCount, err := models.GetInferenceTwoCount(beginTime, endTime)
inferenceTwoCount, err := models.GetInferenceTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query inferenceTwoCount.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
cloudbrainOneCount := debugOneCount + benchmarkOneCount + trainOneCount
cloudbrainTwoCount := debugTwoCount + trainTwoCount + inferenceTwoCount
cloudbrainOneCount, err := models.GetCloudBrainOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query cloudbrainOneCount.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
cloudbrainTwoCount, err := models.GetCloudBrainTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("Can not query cloudbrainOneCount.", err)
return 0, 0, 0, 0, 0, 0, 0, 0, 0, err
}
cloudbrainCount := cloudbrainOneCount + cloudbrainTwoCount
return debugOneCount, benchmarkOneCount, trainOneCount, debugTwoCount, trainTwoCount, inferenceTwoCount, cloudbrainOneCount, cloudbrainTwoCount, cloudbrainCount, err
}


+ 20
- 14
routers/repo/cloudbrain_statistic.go View File

@@ -33,59 +33,65 @@ func CloudbrainStatisticDaily(date string) {
if whichHour == 25 {
beginTime, endTime = models.GetDayStatTime(date)
}
numDubugOne, err := models.GetDebugOneCount(beginTime, endTime)
numDubugOne, err := models.GetDebugOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("GetDebugOneCount failed(%s): %v", numDubugOne, err)
}
numBenchmarkOne, err := models.GetBenchmarkOneCount(beginTime, endTime)
numBenchmarkOne, err := models.GetBenchmarkOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("GetBenchmarkOneCount failed(%s): %v", numBenchmarkOne, err)
}
numTrainOne, err := models.GetTrainOneCount(beginTime, endTime)
numTrainOne, err := models.GetTrainOnePeriodCount(beginTime, endTime)
if err != nil {
log.Error("GetTrainOneCount failed(%s): %v", numTrainOne, err)
}
numDebugTwo, err := models.GetDebugTwoCount(beginTime, endTime)
numDebugTwo, err := models.GetDebugTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("GetDebugTwoCount failed(%s): %v", numDebugTwo, err)
}
numTrainTwo, err := models.GetTrainTwoCount(beginTime, endTime)
numTrainTwo, err := models.GetTrainTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("GetTrainTwoCount failed(%s): %v", numTrainTwo, err)
}
numInferenceTwo, err := models.GetInferenceTwoCount(beginTime, endTime)
numInferenceTwo, err := models.GetInferenceTwoPeriodCount(beginTime, endTime)
if err != nil {
log.Error("GetInferenceTwoCount failed(%s): %v", numInferenceTwo, err)
}
numCloudOneAll := numDubugOne + numBenchmarkOne + numTrainOne
numCloudTwoAll := numDebugTwo + numTrainTwo + numInferenceTwo

durationDubugOne, err := models.GetDebugOneDuration(beginTime, endTime)
durationDubugOne, err := models.GetDebugOnePeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetDebugOneDuration failed(%s): %v", durationDubugOne, err)
}
durationBenchmarkOne, err := models.GetBenchmarkOneDuration(beginTime, endTime)
durationBenchmarkOne, err := models.GetBenchmarkOnePeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetBenchmarkOneDuration failed(%s): %v", durationBenchmarkOne, err)
}
durationTrainOne, err := models.GetTrainOneDuration(beginTime, endTime)
durationTrainOne, err := models.GetTrainOnePeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetTrainOneDuration failed(%s): %v", durationTrainOne, err)
}
durationDebugTwo, err := models.GetDebugTwoDuration(beginTime, endTime)
durationDebugTwo, err := models.GetDebugTwoPeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetDebugTwoDuration failed(%s): %v", durationDebugTwo, err)
}
durationTrainTwo, err := models.GetTrainTwoDuration(beginTime, endTime)
durationTrainTwo, err := models.GetTrainTwoPeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetTrainTwoDuration failed(%s): %v", durationTrainTwo, err)
}
durationInferenceTwo, err := models.GetInferenceTwoDuration(beginTime, endTime)
durationInferenceTwo, err := models.GetInferenceTwoPeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetInferenceTwoDuration failed(%s): %v", durationInferenceTwo, err)
}
durationCloudOneAll := durationDubugOne + durationBenchmarkOne + durationTrainOne
durationCloudTwoAll := durationDebugTwo + durationTrainTwo + durationInferenceTwo
durationCloudOneAll, err := models.GetCloudBrainOnePeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetCloudBrainOnePeriodDuration failed(%s): %v", durationCloudOneAll, err)
}
durationCloudTwoAll, err := models.GetCloudBrainTwoPeriodDuration(beginTime, endTime)
if err != nil {
log.Error("GetCloudBrainTwoPeriodDuration failed(%s): %v", durationCloudTwoAll, err)
}

err = models.CreateCloudbrainStatistic(&models.CloudbrainStatistic{
Date: date,


Loading…
Cancel
Save