build UI
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
||||
// Run represents a run of a workflow file
|
||||
type Run struct {
|
||||
ID int64
|
||||
Name string
|
||||
Title string
|
||||
RepoID int64 `xorm:"index unique(repo_workflow_index)"`
|
||||
Repo *repo_model.Repository `xorm:"-"`
|
||||
WorkflowID string `xorm:"index unique(repo_workflow_index)"` // the name of workflow file
|
||||
@@ -52,6 +52,10 @@ func (Run) TableName() string {
|
||||
return "bots_run"
|
||||
}
|
||||
|
||||
func (run *Run) HTMLURL() string {
|
||||
return fmt.Sprintf("%s/builds/run/%d", run.Repo.HTMLURL(), run.Index)
|
||||
}
|
||||
|
||||
// LoadAttributes load Repo TriggerUser if not loaded
|
||||
func (r *Run) LoadAttributes(ctx context.Context) error {
|
||||
if r == nil {
|
||||
|
||||
@@ -16,10 +16,10 @@ import (
|
||||
type RunList []*Run
|
||||
|
||||
// GetUserIDs returns a slice of user's id
|
||||
func (builds RunList) GetUserIDs() []int64 {
|
||||
func (runs RunList) GetUserIDs() []int64 {
|
||||
userIDsMap := make(map[int64]struct{})
|
||||
for _, build := range builds {
|
||||
userIDsMap[build.TriggerUserID] = struct{}{}
|
||||
for _, run := range runs {
|
||||
userIDsMap[run.TriggerUserID] = struct{}{}
|
||||
}
|
||||
userIDs := make([]int64, 0, len(userIDsMap))
|
||||
for userID := range userIDsMap {
|
||||
@@ -28,14 +28,14 @@ func (builds RunList) GetUserIDs() []int64 {
|
||||
return userIDs
|
||||
}
|
||||
|
||||
func (builds RunList) LoadTriggerUser() error {
|
||||
userIDs := builds.GetUserIDs()
|
||||
func (runs RunList) LoadTriggerUser() error {
|
||||
userIDs := runs.GetUserIDs()
|
||||
users := make(map[int64]*user_model.User, len(userIDs))
|
||||
if err := db.GetEngine(db.DefaultContext).In("id", userIDs).Find(&users); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, task := range builds {
|
||||
task.TriggerUser = users[task.TriggerUserID]
|
||||
for _, run := range runs {
|
||||
run.TriggerUser = users[run.TriggerUserID]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -52,16 +52,14 @@ func (opts FindRunOptions) toConds() builder.Cond {
|
||||
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
|
||||
}
|
||||
if opts.IsClosed.IsFalse() {
|
||||
|
||||
} else if opts.IsClosed.IsTrue() {
|
||||
|
||||
}
|
||||
return cond
|
||||
}
|
||||
|
||||
func FindRuns(ctx context.Context, opts FindRunOptions) (RunList, int64, error) {
|
||||
e := db.GetEngine(ctx).Where(opts.toConds())
|
||||
if opts.PageSize>0&&opts.Page >=1 {
|
||||
if opts.PageSize > 0 && opts.Page >= 1 {
|
||||
e.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
|
||||
}
|
||||
var runs RunList
|
||||
|
||||
@@ -50,7 +50,7 @@ func addBotTables(x *xorm.Engine) error {
|
||||
|
||||
type BotsRun struct {
|
||||
ID int64
|
||||
Name string
|
||||
Title string
|
||||
RepoID int64 `xorm:"index unique(repo_workflow_index)"`
|
||||
WorkflowID string `xorm:"index unique(repo_workflow_index)"` // the name of workflow file
|
||||
Index int64 `xorm:"index unique(repo_workflow_index)"` // a unique number for each run of a particular workflow in a repository
|
||||
|
||||
Reference in New Issue
Block a user