From 0f90bc0633467c1f88256ca75ea935df85c737bc Mon Sep 17 00:00:00 2001 From: Fabian Holler Date: Mon, 6 Jan 2025 14:21:03 +0100 Subject: [PATCH] webinterface: show suspended PRs always in the same order The suspended PRs were shown in random order. When reloading the page, the order might have changed. Show the suspended PRs in the same order then the active PRs, this makes them easier to find. --- internal/autoupdater/httplistdata.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/autoupdater/httplistdata.go b/internal/autoupdater/httplistdata.go index c18b4a5..ba87c5e 100644 --- a/internal/autoupdater/httplistdata.go +++ b/internal/autoupdater/httplistdata.go @@ -3,6 +3,7 @@ package autoupdater import ( "fmt" "net/url" + "slices" "strconv" "time" @@ -50,6 +51,9 @@ func (a *Autoupdater) httpListData() *types.ListData { activePRs, suspendedPRs := queue.asSlices() + // sort them PRs to show list in a stable order in the UI + slices.SortFunc(suspendedPRs, orderBefore) + queueData.ActivePRs = toPagesPullRequests(activePRs) queueData.SuspendedPRs = toPagesPullRequests(suspendedPRs) @@ -64,6 +68,7 @@ func toPagesPullRequests(prs []*PullRequest) []*types.PullRequest { for i, pr := range prs { result = append(result, toPagesPullRequest(pr, i == 0)) } + return result }