From aa8c67d86e94c4a2dc3f59d0f7665c00dac0660a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 21 Feb 2023 00:11:28 +0100 Subject: [PATCH] Order pull request conflict checking by recently updated, for each push When a change is pushed to the default branch and many pull requests are open for that branch, conflict checking can take some time. Previously it would go from oldest to newest pull request. Now prioritize pull requests that are likely being actively worked on or prepared for merging. This only changes the order within one push to one repository, but the change is trivial and can already be quite helpful for smaller Gitea instances where a few repositories have most pull requests. A global order would require deeper changes to queues. --- models/issues/pull_list.go | 1 + 1 file changed, 1 insertion(+) diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go index f4efd916c867..6c9e8c4e05fb 100644 --- a/models/issues/pull_list.go +++ b/models/issues/pull_list.go @@ -111,6 +111,7 @@ func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequ return prs, db.GetEngine(db.DefaultContext). Where("base_repo_id=? AND base_branch=? AND has_merged=? AND issue.is_closed=?", repoID, branch, false, false). + OrderBy("issue.updated_unix DESC"). Join("INNER", "issue", "issue.id=pull_request.issue_id"). Find(&prs) }