| @@ -903,6 +903,52 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { | |||||
| return cloudbrains, count, nil | return cloudbrains, count, nil | ||||
| } | } | ||||
| func QueryModelTrainJobVersionList(jobId string) ([]*CloudbrainInfo, int, error) { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| var cond = builder.NewCond() | |||||
| cond = cond.And( | |||||
| builder.Eq{"cloudbrain.job_id": jobId}, | |||||
| ) | |||||
| cond = cond.And( | |||||
| builder.Eq{"cloudbrain.Status": "COMPLETED"}, | |||||
| ) | |||||
| sess.OrderBy("cloudbrain.created_unix DESC") | |||||
| cloudbrains := make([]*CloudbrainInfo, 0) | |||||
| if err := sess.Table(&Cloudbrain{}).Where(cond). | |||||
| Find(&cloudbrains); err != nil { | |||||
| return nil, 0, fmt.Errorf("Find: %v", err) | |||||
| } | |||||
| return cloudbrains, int(len(cloudbrains)), nil | |||||
| } | |||||
| func QueryModelTrainJobList(repoId int64) ([]*CloudbrainInfo, int, error) { | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| var cond = builder.NewCond() | |||||
| cond = cond.And( | |||||
| builder.Eq{"cloudbrain.repo_id": repoId}, | |||||
| ) | |||||
| cond = cond.And( | |||||
| builder.Eq{"cloudbrain.Status": "COMPLETED"}, | |||||
| ) | |||||
| sess.OrderBy("cloudbrain.created_unix DESC") | |||||
| cloudbrains := make([]*CloudbrainInfo, 0) | |||||
| if err := sess.Distinct("job_id").Table(&Cloudbrain{}).Where(cond). | |||||
| Find(&cloudbrains); err != nil { | |||||
| return nil, 0, fmt.Errorf("Find: %v", err) | |||||
| } | |||||
| return cloudbrains, int(len(cloudbrains)), nil | |||||
| } | |||||
| func CloudbrainsVersionList(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int, error) { | func CloudbrainsVersionList(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int, error) { | ||||
| sess := x.NewSession() | sess := x.NewSession() | ||||
| defer sess.Close() | defer sess.Close() | ||||
| @@ -22,7 +22,6 @@ var customMigrations = []CustomMigration{ | |||||
| } | } | ||||
| var customMigrationsStatic = []CustomMigrationStatic{ | var customMigrationsStatic = []CustomMigrationStatic{ | ||||
| {"Alter user static table field type ", alterUserStaticTable}, | |||||
| {"Delete organization user history data ", deleteNotDisplayUser}, | {"Delete organization user history data ", deleteNotDisplayUser}, | ||||
| {"update issue_fixed_rate to 1 if num_issues is 0 ", updateIssueFixedRate}, | {"update issue_fixed_rate to 1 if num_issues is 0 ", updateIssueFixedRate}, | ||||
| } | } | ||||
| @@ -59,14 +58,6 @@ func syncTopicStruct(x *xorm.Engine) error { | |||||
| return err | return err | ||||
| } | } | ||||
| func alterUserStaticTable(x *xorm.Engine, static *xorm.Engine) error { | |||||
| alterSql := "alter table public.user_business_analysis alter column open_i_index type double precision" | |||||
| _, err := static.Exec(alterSql) | |||||
| return err | |||||
| } | |||||
| func deleteNotDisplayUser(x *xorm.Engine, static *xorm.Engine) error { | func deleteNotDisplayUser(x *xorm.Engine, static *xorm.Engine) error { | ||||
| querySQL := "select id,name from public.user where type=1" | querySQL := "select id,name from public.user where type=1" | ||||
| @@ -261,16 +261,7 @@ func QueryTrainJobVersionList(ctx *context.Context) { | |||||
| log.Info("query train job version list. start.") | log.Info("query train job version list. start.") | ||||
| JobID := ctx.Query("JobID") | JobID := ctx.Query("JobID") | ||||
| VersionListTasks, count, err := models.CloudbrainsVersionList(&models.CloudbrainsOptions{ | |||||
| ListOptions: models.ListOptions{ | |||||
| Page: -1, | |||||
| PageSize: -1, | |||||
| }, | |||||
| RepoID: -1, | |||||
| Type: -1, | |||||
| JobType: "", | |||||
| JobID: JobID, | |||||
| }) | |||||
| VersionListTasks, count, err := models.QueryModelTrainJobVersionList(JobID) | |||||
| log.Info("query return count=" + fmt.Sprint(count)) | log.Info("query return count=" + fmt.Sprint(count)) | ||||
| @@ -285,16 +276,7 @@ func QueryTrainJobList(ctx *context.Context) { | |||||
| log.Info("query train job list. start.") | log.Info("query train job list. start.") | ||||
| repoId := ctx.QueryInt64("repoId") | repoId := ctx.QueryInt64("repoId") | ||||
| VersionListTasks, count, err := models.CloudbrainsVersionList(&models.CloudbrainsOptions{ | |||||
| ListOptions: models.ListOptions{ | |||||
| Page: -1, | |||||
| PageSize: -1, | |||||
| }, | |||||
| RepoID: repoId, | |||||
| Type: -1, | |||||
| JobType: "", | |||||
| JobID: "", | |||||
| }) | |||||
| VersionListTasks, count, err := models.QueryModelTrainJobList(repoId) | |||||
| log.Info("query return count=" + fmt.Sprint(count)) | log.Info("query return count=" + fmt.Sprint(count)) | ||||