mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
Fix filter count
This commit is contained in:
parent
38b36edc5c
commit
b65e263f92
@ -77,3 +77,7 @@ func FindRuns(ctx context.Context, opts FindRunOptions) (RunList, int64, error)
|
||||
total, err := e.Desc("id").FindAndCount(&runs)
|
||||
return runs, total, err
|
||||
}
|
||||
|
||||
func CountRuns(ctx context.Context, opts FindRunOptions) (int64, error) {
|
||||
return db.GetEngine(ctx).Where(opts.toConds()).Count(new(Run))
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ func List(ctx *context.Context) {
|
||||
}
|
||||
|
||||
ctx.Data["workflows"] = workflows
|
||||
ctx.Data["RepoLink"] = ctx.Repo.Repository.HTMLURL()
|
||||
|
||||
page := ctx.FormInt("page")
|
||||
if page <= 0 {
|
||||
@ -76,6 +77,26 @@ func List(ctx *context.Context) {
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
WorkflowFileName: workflow,
|
||||
}
|
||||
|
||||
// open counts
|
||||
opts.IsClosed = util.OptionalBoolFalse
|
||||
numOpenRuns, err := bots_model.CountRuns(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Data["NumOpenRuns"] = numOpenRuns
|
||||
|
||||
// closed counts
|
||||
opts.IsClosed = util.OptionalBoolTrue
|
||||
numClosedRuns, err := bots_model.CountRuns(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Data["NumClosedRuns"] = numClosedRuns
|
||||
|
||||
opts.IsClosed = util.OptionalBoolNone
|
||||
if ctx.FormString("state") == "closed" {
|
||||
opts.IsClosed = util.OptionalBoolTrue
|
||||
} else {
|
||||
|
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div class="desc issue-item-bottom-row df ac fw my-1">
|
||||
<b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>: Commit
|
||||
<a href="{{$.Link}}/commit/{{.CommitSHA}}">{{SubStr .CommitSHA 0 10}}</a> pushed by {{.TriggerUser.GetDisplayName | Escape}}
|
||||
<a href="{{$.RepoLink}}/commit/{{.CommitSHA}}">{{SubStr .CommitSHA 0 10}}</a> pushed by {{.TriggerUser.GetDisplayName | Escape}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="issue-item-right">
|
||||
|
@ -1,10 +1,10 @@
|
||||
<div class="ui compact tiny menu">
|
||||
<a class="{{if not .IsShowClosed}}active{{end}} item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state=open&labels={{.SelectLabels}}&milestone={{.MilestoneID}}&assignee={{.AssigneeID}}">
|
||||
<a class="{{if not .IsShowClosed}}active{{end}} item" href="{{$.Link}}?workflow={{.CurWorkflow}}&state=open">
|
||||
{{svg "octicon-issue-opened" 16 "mr-3"}}
|
||||
{{.locale.Tr "repo.builds.open_tab" .Repository.NumOpenRuns}}
|
||||
{{.locale.Tr "repo.builds.open_tab" $.NumOpenRuns}}
|
||||
</a>
|
||||
<a class="{{if .IsShowClosed}}active{{end}} item" href="{{$.Link}}?q={{$.Keyword}}&type={{.ViewType}}&sort={{$.SortType}}&state=closed&labels={{.SelectLabels}}&milestone={{.MilestoneID}}&assignee={{.AssigneeID}}">
|
||||
<a class="{{if .IsShowClosed}}active{{end}} item" href="{{$.Link}}?workflow={{.CurWorkflow}}&&state=closed">
|
||||
{{svg "octicon-issue-closed" 16 "mr-3"}}
|
||||
{{.locale.Tr "repo.builds.closed_tab" .Repository.NumClosedRuns}}
|
||||
{{.locale.Tr "repo.builds.closed_tab" $.NumClosedRuns}}
|
||||
</a>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user