|
|
|
@@ -66,6 +66,7 @@ func GetAllCloudbrainsOverview(ctx *context.Context) { |
|
|
|
cloudBrainNum := make(map[int]int) |
|
|
|
cloudBrainOneDuration := int64(0) |
|
|
|
cloudBrainTwoDuration := int64(0) |
|
|
|
intelligentNetDuration := int64(0) |
|
|
|
for _, cloudbrain := range cloudbrains { |
|
|
|
if int64(cloudbrain.Cloudbrain.CreatedUnix) >= beginTime.Unix() && int64(cloudbrain.Cloudbrain.CreatedUnix) < endTime.Unix() { |
|
|
|
if _, ok := todayStatusResult[cloudbrain.Status]; !ok { |
|
|
|
@@ -87,6 +88,9 @@ func GetAllCloudbrainsOverview(ctx *context.Context) { |
|
|
|
if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainTwo { |
|
|
|
cloudBrainTwoDuration = cloudBrainTwoDuration + cloudbrain.Cloudbrain.Duration |
|
|
|
} |
|
|
|
if cloudbrain.Cloudbrain.Type == models.TypeIntelligentNet { |
|
|
|
intelligentNetDuration = intelligentNetDuration + cloudbrain.Cloudbrain.Duration |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@@ -107,7 +111,7 @@ func GetAllCloudbrainsOverview(ctx *context.Context) { |
|
|
|
"cloudBrainNum": cloudBrainNum, |
|
|
|
"cloudBrainOneDuration": cloudBrainOneDuration, |
|
|
|
"cloudBrainTwoDuration": cloudBrainTwoDuration, |
|
|
|
"intelligentNetDuration": 0, |
|
|
|
"intelligentNetDuration": intelligentNetDuration, |
|
|
|
"todayCreatorCount": todayCreatorCount, |
|
|
|
"creatorCount": creatorCount, |
|
|
|
"todayRunningCount": todayRunningCount, |
|
|
|
@@ -117,12 +121,20 @@ func GetAllCloudbrainsOverview(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
func GetAllCloudbrainsTrend(ctx *context.Context) { |
|
|
|
brainRecordBeginTime, err := getBrainRecordBeginTime() |
|
|
|
recordCloudbrain, err := models.GetRecordBeginTime() |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not get brain record begin time", err) |
|
|
|
ctx.Error(http.StatusBadRequest, ctx.Tr("repo.brain_record_begintime_get_err")) |
|
|
|
log.Error("Can not get record begin time", err) |
|
|
|
ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) |
|
|
|
return |
|
|
|
} |
|
|
|
recordTime := time.Unix(int64(recordCloudbrain[0].Cloudbrain.CreatedUnix), 0).Format(CREATE_TIME_FORMAT) |
|
|
|
brainRecordBeginTime, _ := time.Parse("2006-01-02 15:04:05", recordTime) |
|
|
|
// brainRecordBeginTime, err := getBrainRecordBeginTime() |
|
|
|
// if err != nil { |
|
|
|
// log.Error("Can not get brain record begin time", err) |
|
|
|
// ctx.Error(http.StatusBadRequest, ctx.Tr("repo.brain_record_begintime_get_err")) |
|
|
|
// return |
|
|
|
// } |
|
|
|
queryType := ctx.QueryTrim("type") |
|
|
|
now := time.Now() |
|
|
|
|
|
|
|
@@ -334,12 +346,20 @@ func getPageDateCloudbrainNum(dateCloudbrainNums []DateCloudbrainNum, page int, |
|
|
|
} |
|
|
|
|
|
|
|
func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { |
|
|
|
recordBeginTime, err := getBrainRecordBeginTime() |
|
|
|
recordCloudbrain, err := models.GetRecordBeginTime() |
|
|
|
if err != nil { |
|
|
|
log.Error("Can not get record begin time", err) |
|
|
|
ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) |
|
|
|
return |
|
|
|
} |
|
|
|
recordTime := time.Unix(int64(recordCloudbrain[0].Cloudbrain.CreatedUnix), 0).Format(CREATE_TIME_FORMAT) |
|
|
|
recordBeginTime, _ := time.Parse("2006-01-02 15:04:05", recordTime) |
|
|
|
// recordBeginTime, err := getBrainRecordBeginTime() |
|
|
|
// if err != nil { |
|
|
|
// log.Error("Can not get record begin time", err) |
|
|
|
// ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) |
|
|
|
// return |
|
|
|
// } |
|
|
|
beginTime, endTime, err := getTimePeroid(ctx, recordBeginTime) |
|
|
|
if err != nil { |
|
|
|
log.Error("Parameter is wrong", err) |
|
|
|
@@ -373,6 +393,13 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { |
|
|
|
cloudTwoJobTypeRes[cloudbrain.JobType] += 1 |
|
|
|
} |
|
|
|
} |
|
|
|
if cloudbrain.Cloudbrain.Type == models.TypeIntelligentNet { |
|
|
|
if _, ok := intelligentNetJobTypeRes[cloudbrain.JobType]; !ok { |
|
|
|
intelligentNetJobTypeRes[cloudbrain.JobType] = 1 |
|
|
|
} else { |
|
|
|
intelligentNetJobTypeRes[cloudbrain.JobType] += 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if _, ok := cloudBrainPeriodNum[cloudbrain.Cloudbrain.Type]; !ok { |
|
|
|
cloudBrainPeriodNum[cloudbrain.Cloudbrain.Type] = 1 |
|
|
|
|