@@ -1680,21 +1680,6 @@ func GetCloudbrainsNeededStopByUserID(userID int64) ([]*Cloudbrain, error) { | |||||
return cloudBrains, err | return cloudBrains, err | ||||
} | } | ||||
func GetWaittingTop() ([]*CloudbrainInfo, error) { | |||||
sess := x.NewSession() | |||||
defer sess.Close() | |||||
var cond = builder.NewCond() | |||||
cond = cond.And( | |||||
builder.Eq{"cloudbrain.status": string(JobWaiting)}, | |||||
) | |||||
sess.OrderBy("cloudbrain.created_unix ASC limit 1") | |||||
cloudbrains := make([]*CloudbrainInfo, 0, 1) | |||||
if err := sess.Table(&Cloudbrain{}).Where(cond). | |||||
Find(&cloudbrains); err != nil { | |||||
log.Info("find error.") | |||||
} | |||||
return cloudbrains, nil | |||||
} | |||||
func GetModelartsReDebugTaskByJobId(jobID string) ([]*Cloudbrain, error) { | func GetModelartsReDebugTaskByJobId(jobID string) ([]*Cloudbrain, error) { | ||||
sess := x.NewSession() | sess := x.NewSession() | ||||
defer sess.Close() | defer sess.Close() | ||||
@@ -36,133 +36,6 @@ type TaskDetail struct { | |||||
FlavorName string `json:"FlavorName"` | FlavorName string `json:"FlavorName"` | ||||
} | } | ||||
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) + | |||||
" and job_type ='" + string(JobTypeDebug) + "'" + | |||||
" and type='" + strconv.Itoa(TypeCloudBrainOne) + "'" | |||||
return x.SQL(countSql).Count() | |||||
} | |||||
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 | |||||
} | |||||
return total, nil | |||||
} | |||||
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) + | |||||
" and job_type ='" + string(JobTypeTrain) + "'" + | |||||
" and type='" + strconv.Itoa(TypeCloudBrainOne) + "'" | |||||
return x.SQL(countSql).Count() | |||||
} | |||||
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 | |||||
} | |||||
return total, nil | |||||
} | |||||
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) + | |||||
" and job_type ='" + string(JobTypeBenchmark) + "'" + | |||||
" and type='" + strconv.Itoa(TypeCloudBrainOne) + "'" | |||||
return x.SQL(countSql).Count() | |||||
} | |||||
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 | |||||
} | |||||
return total, nil | |||||
} | |||||
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) + | |||||
" and job_type ='" + string(JobTypeDebug) + "'" + | |||||
" and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'" | |||||
return x.SQL(countSql).Count() | |||||
} | |||||
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 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) + | |||||
" and job_type ='" + string(JobTypeTrain) + "'" + | |||||
" and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'" | |||||
return x.SQL(countSql).Count() | |||||
} | |||||
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 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) + | |||||
" and job_type ='" + string(JobTypeInference) + "'" + | |||||
" and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'" | |||||
return x.SQL(countSql).Count() | |||||
} | |||||
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 | |||||
} | |||||
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 GetTodayCreatorCount(beginTime time.Time, endTime time.Time) (int64, error) { | func GetTodayCreatorCount(beginTime time.Time, endTime time.Time) (int64, error) { | ||||
countSql := "SELECT count(distinct user_id) FROM " + | countSql := "SELECT count(distinct user_id) FROM " + | ||||
"public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | ||||
@@ -211,6 +84,22 @@ func GetAllStatusCloudBrain() map[string]int { | |||||
return cloudBrainStatusResult | return cloudBrainStatusResult | ||||
} | } | ||||
func GetWaittingTop() ([]*CloudbrainInfo, error) { | |||||
sess := x.NewSession() | |||||
defer sess.Close() | |||||
var cond = builder.NewCond() | |||||
cond = cond.And( | |||||
builder.Eq{"cloudbrain.status": string(JobWaiting)}, | |||||
) | |||||
sess.OrderBy("cloudbrain.created_unix ASC limit 10") | |||||
cloudbrains := make([]*CloudbrainInfo, 0, 10) | |||||
if err := sess.Table(&Cloudbrain{}).Where(cond). | |||||
Find(&cloudbrains); err != nil { | |||||
log.Info("find error.") | |||||
} | |||||
return cloudbrains, nil | |||||
} | |||||
func GetRunningTop() ([]*CloudbrainInfo, error) { | func GetRunningTop() ([]*CloudbrainInfo, error) { | ||||
sess := x.NewSession() | sess := x.NewSession() | ||||
defer sess.Close() | defer sess.Close() | ||||
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》