From f361f29e1420e86e42a76c849b30999c4b2ebf6f Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Sun, 1 Jun 2025 13:08:14 +0100 Subject: [PATCH] appview: pulls: group stacked pulls in all-pulls view Change-Id: ykwytywspowpxxvpornqsnzwztywnyol the pull listing should be less noisy now. Signed-off-by: oppiliappan --- appview/pages/pages.go | 1 + appview/pages/templates/repo/pulls/pulls.html | 38 ++++++++++++++++++- appview/pulls/pulls.go | 23 +++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/appview/pages/pages.go b/appview/pages/pages.go index acea227..67a7583 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -721,6 +721,7 @@ type RepoPullsParams struct { Active string DidHandleMap map[string]string FilteringBy db.PullState + Stacks map[string]db.Stack } func (p *Pages) RepoPulls(w io.Writer, params RepoPullsParams) error { diff --git a/appview/pages/templates/repo/pulls/pulls.html b/appview/pages/templates/repo/pulls/pulls.html index ea5c9ea..f9afe60 100644 --- a/appview/pages/templates/repo/pulls/pulls.html +++ b/appview/pages/templates/repo/pulls/pulls.html @@ -46,7 +46,8 @@ {{ define "repoAfter" }}
{{ range .Pulls }} -
+ {{ end }} + +{{ define "pullList" }} + {{ $list := index . 0 }} + {{ $root := index . 1 }} + +{{ end }} diff --git a/appview/pulls/pulls.go b/appview/pulls/pulls.go index 6cbd3c6..abc59a9 100644 --- a/appview/pulls/pulls.go +++ b/appview/pulls/pulls.go @@ -495,6 +495,28 @@ func (s *Pulls) RepoPulls(w http.ResponseWriter, r *http.Request) { } } + // we want to group all stacked PRs into just one list + stacks := make(map[string]db.Stack) + n := 0 + for _, p := range pulls { + // this PR is stacked + if p.StackId != "" { + // we have already seen this PR stack + if _, seen := stacks[p.StackId]; seen { + stacks[p.StackId] = append(stacks[p.StackId], p) + // skip this PR + } else { + stacks[p.StackId] = nil + pulls[n] = p + n++ + } + } else { + pulls[n] = p + n++ + } + } + pulls = pulls[:n] + identsToResolve := make([]string, len(pulls)) for i, pull := range pulls { identsToResolve[i] = pull.OwnerDid @@ -515,6 +537,7 @@ func (s *Pulls) RepoPulls(w http.ResponseWriter, r *http.Request) { Pulls: pulls, DidHandleMap: didHandleMap, FilteringBy: state, + Stacks: stacks, }) return } -- 2.43.0