Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Drop `IDOrderDesc` for listing Actions task and always order by `id DESC` (go-gitea#31150)
  Fix branch order (go-gitea#31174)
  • Loading branch information
zjjhot committed May 31, 2024
2 parents c74b94c + 572fa55 commit 12e3fc3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
6 changes: 1 addition & 5 deletions models/actions/task_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type FindTaskOptions struct {
UpdatedBefore timeutil.TimeStamp
StartedBefore timeutil.TimeStamp
RunnerID int64
IDOrderDesc bool
}

func (opts FindTaskOptions) ToConds() builder.Cond {
Expand Down Expand Up @@ -84,8 +83,5 @@ func (opts FindTaskOptions) ToConds() builder.Cond {
}

func (opts FindTaskOptions) ToOrders() string {
if opts.IDOrderDesc {
return "`id` DESC"
}
return ""
return "`id` DESC"
}
12 changes: 4 additions & 8 deletions models/git/branch_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,13 @@ func (opts FindBranchOptions) ToConds() builder.Cond {

func (opts FindBranchOptions) ToOrders() string {
orderBy := opts.OrderBy
if opts.IsDeletedBranch.ValueOrDefault(true) { // if deleted branch included, put them at the end
if orderBy != "" {
orderBy += ", "
}
orderBy += "is_deleted ASC"
}
if orderBy == "" {
// the commit_time might be the same, so add the "name" to make sure the order is stable
return "commit_time DESC, name ASC"
orderBy = "commit_time DESC, name ASC"
}
if opts.IsDeletedBranch.ValueOrDefault(true) { // if deleted branch included, put them at the beginning
orderBy = "is_deleted ASC, " + orderBy
}

return orderBy
}

Expand Down
5 changes: 2 additions & 3 deletions routers/web/shared/actions/runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ func RunnerDetails(ctx *context.Context, page int, runnerID, ownerID, repoID int
Page: page,
PageSize: 30,
},
Status: actions_model.StatusUnknown, // Unknown means all
IDOrderDesc: true,
RunnerID: runner.ID,
Status: actions_model.StatusUnknown, // Unknown means all
RunnerID: runner.ID,
}

tasks, count, err := db.FindAndCount[actions_model.ActionTask](ctx, opts)
Expand Down

0 comments on commit 12e3fc3

Please sign in to comment.