From 90713c455268259046c7b0d0c2bdfc1b4243a5c4 Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 13 Jun 2022 18:39:51 +0800 Subject: [PATCH] fix-bug --- routers/api/v1/repo/cloudbrain_dashboard.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index c738281c3..f9f3955bb 100644 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -460,6 +460,9 @@ func getPageDateCloudbrainInfo(dateCloudbrainInfo []DateCloudbrainInfo, page int } func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { + queryType := ctx.QueryTrim("type") + beginTimeStr := ctx.QueryTrim("beginTime") + endTimeStr := ctx.QueryTrim("endTime") recordCloudbrain, err := models.GetRecordBeginTime() if err != nil { log.Error("Can not get record begin time", err) @@ -474,8 +477,6 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { ctx.Error(http.StatusBadRequest, ctx.Tr("repo.parameter_is_wrong")) return } - log.Info("ssssdistrubuydst:", beginTime) - log.Info("endTime:", endTime) cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ Type: models.TypeCloudBrainAll, @@ -489,8 +490,12 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { intelligentNetJobTypeRes := make(map[string]int) cloudBrainPeriodNum := make(map[int]int) cloudBrainComputeResource := make(map[string]int) + beginTimeTemp := beginTime.Unix() + if queryType == "all" || (queryType == "" && (beginTimeStr == "" || endTimeStr == "")) { + beginTimeTemp = int64(recordCloudbrain[0].Cloudbrain.CreatedUnix) + } for _, cloudbrain := range cloudbrains { - if int64(cloudbrain.Cloudbrain.CreatedUnix) >= beginTime.Unix() && int64(cloudbrain.Cloudbrain.CreatedUnix) < endTime.Unix() { + if int64(cloudbrain.Cloudbrain.CreatedUnix) >= beginTimeTemp && int64(cloudbrain.Cloudbrain.CreatedUnix) <= endTime.Unix() { if cloudbrain.Cloudbrain.Type == models.TypeCloudBrainOne { if _, ok := cloudOneJobTypeRes[cloudbrain.JobType]; !ok { cloudOneJobTypeRes[cloudbrain.JobType] = 1 @@ -1248,10 +1253,10 @@ func getBrainDeleteTime(rs *models.CloudbrainInfo) string { } func getCloudbrainTimePeroid(ctx *context.Context, recordBeginTime time.Time) (time.Time, time.Time, error) { queryType := ctx.QueryTrim("type") - now := time.Now() - beginTimeStr := ctx.QueryTrim("beginTime") endTimeStr := ctx.QueryTrim("endTime") + now := time.Now() + var beginTime time.Time var endTime time.Time var err error @@ -1315,9 +1320,6 @@ func getCloudbrainTimePeroid(ctx *context.Context, recordBeginTime time.Time) (t if err != nil { return now, now, err } - - // beginTime = beginTime.AddDate(0, 0, 1) - // endTime = endTime.AddDate(0, 0, 1) } }