| @@ -460,6 +460,9 @@ func getPageDateCloudbrainInfo(dateCloudbrainInfo []DateCloudbrainInfo, page int | |||||
| } | } | ||||
| func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { | func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { | ||||
| queryType := ctx.QueryTrim("type") | |||||
| beginTimeStr := ctx.QueryTrim("beginTime") | |||||
| endTimeStr := ctx.QueryTrim("endTime") | |||||
| recordCloudbrain, err := models.GetRecordBeginTime() | recordCloudbrain, err := models.GetRecordBeginTime() | ||||
| if err != nil { | if err != nil { | ||||
| log.Error("Can not get record begin time", err) | 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")) | ctx.Error(http.StatusBadRequest, ctx.Tr("repo.parameter_is_wrong")) | ||||
| return | return | ||||
| } | } | ||||
| log.Info("ssssdistrubuydst:", beginTime) | |||||
| log.Info("endTime:", endTime) | |||||
| cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ | cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ | ||||
| Type: models.TypeCloudBrainAll, | Type: models.TypeCloudBrainAll, | ||||
| @@ -489,8 +490,12 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { | |||||
| intelligentNetJobTypeRes := make(map[string]int) | intelligentNetJobTypeRes := make(map[string]int) | ||||
| cloudBrainPeriodNum := make(map[int]int) | cloudBrainPeriodNum := make(map[int]int) | ||||
| cloudBrainComputeResource := make(map[string]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 { | 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 cloudbrain.Cloudbrain.Type == models.TypeCloudBrainOne { | ||||
| if _, ok := cloudOneJobTypeRes[cloudbrain.JobType]; !ok { | if _, ok := cloudOneJobTypeRes[cloudbrain.JobType]; !ok { | ||||
| cloudOneJobTypeRes[cloudbrain.JobType] = 1 | 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) { | func getCloudbrainTimePeroid(ctx *context.Context, recordBeginTime time.Time) (time.Time, time.Time, error) { | ||||
| queryType := ctx.QueryTrim("type") | queryType := ctx.QueryTrim("type") | ||||
| now := time.Now() | |||||
| beginTimeStr := ctx.QueryTrim("beginTime") | beginTimeStr := ctx.QueryTrim("beginTime") | ||||
| endTimeStr := ctx.QueryTrim("endTime") | endTimeStr := ctx.QueryTrim("endTime") | ||||
| now := time.Now() | |||||
| var beginTime time.Time | var beginTime time.Time | ||||
| var endTime time.Time | var endTime time.Time | ||||
| var err error | var err error | ||||
| @@ -1315,9 +1320,6 @@ func getCloudbrainTimePeroid(ctx *context.Context, recordBeginTime time.Time) (t | |||||
| if err != nil { | if err != nil { | ||||
| return now, now, err | return now, now, err | ||||
| } | } | ||||
| // beginTime = beginTime.AddDate(0, 0, 1) | |||||
| // endTime = endTime.AddDate(0, 0, 1) | |||||
| } | } | ||||
| } | } | ||||