|
|
@@ -453,29 +453,32 @@ type GetImagesPayload struct { |
|
|
|
|
|
|
|
type CloudbrainsOptions struct { |
|
|
|
ListOptions |
|
|
|
RepoID int64 // include all repos if empty |
|
|
|
UserID int64 |
|
|
|
JobID string |
|
|
|
SortType string |
|
|
|
CloudbrainIDs []int64 |
|
|
|
JobStatus []string |
|
|
|
JobStatusNot bool |
|
|
|
Keyword string |
|
|
|
Type int |
|
|
|
JobTypes []string |
|
|
|
VersionName string |
|
|
|
IsLatestVersion string |
|
|
|
JobTypeNot bool |
|
|
|
NeedRepoInfo bool |
|
|
|
RepoIDList []int64 |
|
|
|
BeginTime time.Time |
|
|
|
EndTime time.Time |
|
|
|
ComputeResource string |
|
|
|
BeginTimeUnix int64 |
|
|
|
EndTimeUnix int64 |
|
|
|
AiCenter string |
|
|
|
NeedDeleteInfo string |
|
|
|
Cluster string |
|
|
|
RepoID int64 // include all repos if empty |
|
|
|
UserID int64 |
|
|
|
JobID string |
|
|
|
SortType string |
|
|
|
CloudbrainIDs []int64 |
|
|
|
JobStatus []string |
|
|
|
JobStatusNot bool |
|
|
|
Keyword string |
|
|
|
Type int |
|
|
|
JobTypes []string |
|
|
|
VersionName string |
|
|
|
IsLatestVersion string |
|
|
|
JobTypeNot bool |
|
|
|
NeedRepoInfo bool |
|
|
|
RepoIDList []int64 |
|
|
|
BeginTime time.Time |
|
|
|
EndTime time.Time |
|
|
|
ComputeResource string |
|
|
|
BeginTimeUnix int64 |
|
|
|
EndTimeUnix int64 |
|
|
|
AiCenter string |
|
|
|
NeedDeleteInfo string |
|
|
|
Cluster string |
|
|
|
AccCardType string |
|
|
|
AccCardsNum int |
|
|
|
WorkServerNumber int |
|
|
|
} |
|
|
|
|
|
|
|
type TaskPod struct { |
|
|
@@ -2435,18 +2438,44 @@ func CloudbrainAll(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
if opts.WorkServerNumber > 0 { |
|
|
|
if opts.WorkServerNumber == 1 { |
|
|
|
cond = cond.And(builder.Or( |
|
|
|
builder.Eq{"cloudbrain.work_server_number": 0}, |
|
|
|
builder.Eq{"cloudbrain.work_server_number": 1}, |
|
|
|
builder.IsNull{"cloudbrain.work_server_number"}, |
|
|
|
)) |
|
|
|
} else { |
|
|
|
cond = cond.And( |
|
|
|
builder.Eq{"cloudbrain.work_server_number": opts.WorkServerNumber}, |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if opts.AccCardType != "" { |
|
|
|
cond = cond.And(builder.Eq{"cloudbrain_spec.acc_card_type": opts.AccCardType}) |
|
|
|
} |
|
|
|
if opts.AccCardsNum >= 0 { |
|
|
|
cond = cond.And(builder.Eq{"cloudbrain_spec.acc_cards_num": opts.AccCardsNum}) |
|
|
|
} |
|
|
|
|
|
|
|
var count int64 |
|
|
|
var err error |
|
|
|
condition := "cloudbrain.user_id = `user`.id" |
|
|
|
if len(opts.Keyword) == 0 { |
|
|
|
count, err = sess.Unscoped().Where(cond).Count(new(Cloudbrain)) |
|
|
|
count, err = sess.Table(&Cloudbrain{}).Unscoped().Where(cond). |
|
|
|
Join("left", "`user`", condition). |
|
|
|
Join("left", "cloudbrain_spec", "cloudbrain.id = cloudbrain_spec.cloudbrain_id"). |
|
|
|
Count(new(CloudbrainInfo)) |
|
|
|
} else { |
|
|
|
lowerKeyWord := strings.ToLower(opts.Keyword) |
|
|
|
|
|
|
|
cond = cond.And(builder.Or(builder.Like{"LOWER(cloudbrain.job_name)", lowerKeyWord}, |
|
|
|
builder.Like{"LOWER(cloudbrain.display_job_name)", lowerKeyWord}, builder.Like{"`user`.lower_name", lowerKeyWord})) |
|
|
|
count, err = sess.Table(&Cloudbrain{}).Unscoped().Where(cond). |
|
|
|
Join("left", "`user`", condition).Count(new(CloudbrainInfo)) |
|
|
|
Join("left", "`user`", condition). |
|
|
|
Join("left", "cloudbrain_spec", "cloudbrain.id = cloudbrain_spec.cloudbrain_id"). |
|
|
|
Count(new(CloudbrainInfo)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@@ -2468,6 +2497,7 @@ func CloudbrainAll(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { |
|
|
|
cloudbrains := make([]*CloudbrainInfo, 0, setting.UI.IssuePagingNum) |
|
|
|
if err := sess.Table(&Cloudbrain{}).Unscoped().Where(cond). |
|
|
|
Join("left", "`user`", condition). |
|
|
|
Join("left", "cloudbrain_spec", "cloudbrain.id = cloudbrain_spec.cloudbrain_id"). |
|
|
|
Find(&cloudbrains); err != nil { |
|
|
|
return nil, 0, fmt.Errorf("Find: %v", err) |
|
|
|
} |
|
|
|