diff --git a/models/cloudbrain.go b/models/cloudbrain.go index f54bbfbf9..5a817bbca 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -964,12 +964,21 @@ func QueryModelTrainJobList(repoId int64) ([]*CloudbrainInfo, int, error) { ) cloudbrains := make([]*CloudbrainInfo, 0) - if err := sess.Select("job_id,job_name").Table(&Cloudbrain{}).Where("job_id in (?)", sess.Distinct("job_id").Table(&Cloudbrain{}).Where(cond)).OrderBy("created_unix DESC"). + if err := sess.Select("job_id,job_name").Table(&Cloudbrain{}).Where(cond).OrderBy("created_unix DESC"). Find(&cloudbrains); err != nil { return nil, 0, fmt.Errorf("Find: %v", err) } - return cloudbrains, int(len(cloudbrains)), nil + keys := make(map[string]string) + uniqueElements := make([]*CloudbrainInfo, 0) + for _, entry := range cloudbrains { + if _, value := keys[entry.JobID]; !value { + keys[entry.JobID] = entry.JobName + uniqueElements = append(uniqueElements, entry) + } + } + + return uniqueElements, int(len(uniqueElements)), nil } func CloudbrainsVersionList(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int, error) {