diff --git a/models/bots/run.go b/models/bots/run.go index 8a5c5efc15..ed8bfdd711 100644 --- a/models/bots/run.go +++ b/models/bots/run.go @@ -56,27 +56,6 @@ func (run *Run) HTMLURL() string { return fmt.Sprintf("%s/builds/run/%d", run.Repo.HTMLURL(), run.Index) } -func (run *Run) IsPending() bool { - return run.Status == core.StatusWaiting || run.Status == core.StatusPending -} - -func (run *Run) IsRunning() bool { - return run.Status == core.StatusRunning -} - -func (run *Run) IsSuccess() bool { - return run.Status == core.StatusPassing -} - -func (run *Run) IsFailed() bool { - return run.Status == core.StatusFailing || - run.Status == core.StatusKilled || - run.Status == core.StatusError || - run.Status == core.StatusSkipped || - run.Status == core.StatusBlocked || - run.Status == core.StatusDeclined -} - // LoadAttributes load Repo TriggerUser if not loaded func (r *Run) LoadAttributes(ctx context.Context) error { if r == nil { diff --git a/models/bots/run_list.go b/models/bots/run_list.go index e2c5b33607..eb9bf7f9f0 100644 --- a/models/bots/run_list.go +++ b/models/bots/run_list.go @@ -7,6 +7,7 @@ package bots import ( "context" + "code.gitea.io/gitea/core" "code.gitea.io/gitea/models/db" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/util" @@ -42,8 +43,9 @@ func (runs RunList) LoadTriggerUser() error { type FindRunOptions struct { db.ListOptions - RepoID int64 - IsClosed util.OptionalBool + RepoID int64 + IsClosed util.OptionalBool + WorkflowFileName string } func (opts FindRunOptions) toConds() builder.Cond { @@ -52,7 +54,16 @@ func (opts FindRunOptions) toConds() builder.Cond { cond = cond.And(builder.Eq{"repo_id": opts.RepoID}) } if opts.IsClosed.IsFalse() { + cond = cond.And(builder.Eq{"status": core.StatusPending}.Or( + builder.Eq{"status": core.StatusWaiting}.Or( + builder.Eq{"status": core.StatusRunning}))) } else if opts.IsClosed.IsTrue() { + cond = cond.And(builder.Neq{"status": core.StatusPending}.And( + builder.Neq{"status": core.StatusWaiting}.And( + builder.Neq{"status": core.StatusRunning}))) + } + if opts.WorkflowFileName != "" { + cond = cond.And(builder.Eq{"workflow_id": opts.WorkflowFileName}) } return cond } @@ -63,6 +74,6 @@ func FindRuns(ctx context.Context, opts FindRunOptions) (RunList, int64, error) e.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) } var runs RunList - total, err := e.FindAndCount(&runs) + total, err := e.Desc("id").FindAndCount(&runs) return runs, total, err } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 5c9266050f..138ceec345 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1222,6 +1222,8 @@ projects.board.assigned_to = Assigned to builds = Builds builds.desc = Manage builds builds.opened_by = opened %[1]s by %[2]s +builds.open_tab = %d Open +builds.closed_tab = %d Closed issues.desc = Organize bug reports, tasks and milestones. issues.filter_assignees = Filter Assignee diff --git a/routers/web/repo/builds/builds.go b/routers/web/repo/builds/builds.go index 7db75ff8c8..55fb5c32c0 100644 --- a/routers/web/repo/builds/builds.go +++ b/routers/web/repo/builds/builds.go @@ -70,7 +70,8 @@ func List(ctx *context.Context) { Page: page, PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")), }, - RepoID: ctx.Repo.Repository.ID, + RepoID: ctx.Repo.Repository.ID, + WorkflowFileName: ctx.FormString("workflow"), } if ctx.FormString("state") == "closed" { opts.IsClosed = util.OptionalBoolTrue diff --git a/templates/repo/builds/openclose.tmpl b/templates/repo/builds/openclose.tmpl index fb42e761ca..6856e194d3 100644 --- a/templates/repo/builds/openclose.tmpl +++ b/templates/repo/builds/openclose.tmpl @@ -1,10 +1,10 @@