|
|
|
@@ -26,47 +26,6 @@ type TaskDetail struct { |
|
|
|
RepoID int64 `json:"RepoID"` |
|
|
|
} |
|
|
|
|
|
|
|
// func GetJobWaitingPeriodCount(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(JobWaiting) + "'" |
|
|
|
|
|
|
|
// return x.SQL(countSql).Count() |
|
|
|
// } |
|
|
|
// func GetJobRunningPeriodCount(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(JobRunning) + "'" |
|
|
|
|
|
|
|
// return x.SQL(countSql).Count() |
|
|
|
// } |
|
|
|
// func GetJobStoppedPeriodCount(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 GetJobSucceededPeriodCount(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(JobSucceeded) + "'" |
|
|
|
|
|
|
|
// return x.SQL(countSql).Count() |
|
|
|
// } |
|
|
|
// func GetJobFailedPeriodCount(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 GetDebugOnePeriodCount(beginTime time.Time, endTime time.Time) (int64, error) { |
|
|
|
countSql := "SELECT count(*) FROM " + |
|
|
|
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + |
|
|
|
@@ -216,38 +175,28 @@ func GetAllCloudBrain() ([]*CloudbrainInfo, error) { |
|
|
|
return cloudbrains, nil |
|
|
|
} |
|
|
|
|
|
|
|
// func GetCloudBrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, error) { |
|
|
|
// sess := x.NewSession() |
|
|
|
// defer sess.Close() |
|
|
|
// var cond = builder.NewCond() |
|
|
|
// if len(opts.JobStatus) > 0 { |
|
|
|
// if opts.JobStatusNot { |
|
|
|
// cond = cond.And( |
|
|
|
// builder.NotIn("cloudbrain.status", opts.JobStatus), |
|
|
|
// ) |
|
|
|
// } else { |
|
|
|
// cond = cond.And( |
|
|
|
// builder.In("cloudbrain.status", opts.JobStatus), |
|
|
|
// ) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if opts.Page >= 0 && opts.PageSize > 0 { |
|
|
|
// var start int |
|
|
|
// if opts.Page == 0 { |
|
|
|
// start = 0 |
|
|
|
// } else { |
|
|
|
// start = (opts.Page - 1) * opts.PageSize |
|
|
|
// } |
|
|
|
// sess.Limit(opts.PageSize, start) |
|
|
|
// } |
|
|
|
// sess.OrderBy("cloudbrain.created_unix DESC") |
|
|
|
// cloudbrains := make([]*CloudbrainInfo, 0, setting.UI.IssuePagingNum) |
|
|
|
// if err := sess.Table(&Cloudbrain{}).Where(cond).Unscoped(). |
|
|
|
// Find(&cloudbrains); err != nil { |
|
|
|
// log.Info("find error.") |
|
|
|
// } |
|
|
|
// return cloudbrains, nil |
|
|
|
// } |
|
|
|
func GetRecordBeginTime() ([]*CloudbrainInfo, error) { |
|
|
|
// sess := x.NewSession() |
|
|
|
// defer sess.Close() |
|
|
|
|
|
|
|
// cloudbrains := make([]*CloudbrainInfo, 0) |
|
|
|
// if err := sess.Table(&Cloudbrain{}). |
|
|
|
// Find(&cloudbrains); err != nil { |
|
|
|
// return nil, fmt.Errorf("Find: %v", err) |
|
|
|
// } |
|
|
|
|
|
|
|
// return cloudbrains, nil |
|
|
|
|
|
|
|
sess := x.NewSession() |
|
|
|
defer sess.Close() |
|
|
|
sess.OrderBy("cloudbrain.created_unix ASC limit 1") |
|
|
|
cloudbrains := make([]*CloudbrainInfo, 0) |
|
|
|
if err := sess.Table(&Cloudbrain{}).Unscoped(). |
|
|
|
Find(&cloudbrains); err != nil { |
|
|
|
log.Info("find error.") |
|
|
|
} |
|
|
|
return cloudbrains, nil |
|
|
|
} |
|
|
|
|
|
|
|
func getCreatePeriodCount(dateBeginTime string, dateEndTime string, hourBeginTime string, hourEndTime string) (int64, error) { |
|
|
|
countSql := "SELECT count(*) FROM " + |
|
|
|
|