|
|
@@ -1,6 +1,7 @@ |
|
|
|
package models |
|
|
|
|
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
@@ -75,6 +76,7 @@ type CloudbrainsOptions struct { |
|
|
|
ListOptions |
|
|
|
RepoID int64 // include all repos if empty |
|
|
|
UserID int64 |
|
|
|
JobID int64 |
|
|
|
JobStatus CloudbrainStatus |
|
|
|
SortType string |
|
|
|
CloudbrainIDs []int64 |
|
|
@@ -97,6 +99,12 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*Cloudbrain, int64, error) { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
if (opts.JobID) > 0 { |
|
|
|
cond.And( |
|
|
|
builder.Eq{"cloudbrain.job_id": opts.JobID}, |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
switch opts.JobStatus { |
|
|
|
case JobWaiting: |
|
|
|
cond.And(builder.Eq{"cloudbrain.status": int(JobWaiting)}) |
|
|
@@ -144,3 +152,14 @@ func CreateCloudbrain(cloudbrain *Cloudbrain) (err error) { |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func GetCloudbrainByJobID(jobID string) (*Cloudbrain, error) { |
|
|
|
cb := &Cloudbrain{JobID: jobID} |
|
|
|
has, err := x.Get(cb) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} else if !has { |
|
|
|
return nil, errors.New("cloudbrain task is not found") |
|
|
|
} |
|
|
|
return cb, nil |
|
|
|
} |