detached ec131d8

refactor(issues): move issue event ordering into the domain

commit
ec131d8f5ecbe0d10c74573eac4008aac1913ff2
author
brice · · 2026-10-22 18:26 UTC
committer
brice · · 2026-10-22 18:41 UTC
parent
ccabeff
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +14 -18
M internal/adapters/kvstore/issue_links.go +1 -18
@@ -178,24 +178,7 @@ func (l *IssueLinks) EventsOfMergeRequest(ctx context.Context, repo domain.RepoN
178178 }
179179 out = append(out, ev)
180180 }
181- slices.SortFunc(out, func(a, b domain.IssueEvent) int {
182- if c := a.CreatedAt.Compare(b.CreatedAt); c != 0 {
183- return c
184- }
185- if a.Issue < b.Issue {
186- return -1
187- }
188- if a.Issue > b.Issue {
189- return 1
190- }
191- if a.ID < b.ID {
192- return -1
193- }
194- if a.ID > b.ID {
195- return 1
196- }
197- return 0
198- })
181+ slices.SortFunc(out, domain.CompareIssueEvents)
199182 if len(out) > MaxIssueEvents {
200183 out = out[:MaxIssueEvents]
201184 }
@@ -178,24 +178,7 @@ func (l *IssueLinks) EventsOfMergeRequest(ctx context.Context, repo domain.RepoN
178 }178 }
179 out = append(out, ev)179 out = append(out, ev)
180 }180 }
181- slices.SortFunc(out, func(a, b domain.IssueEvent) int {181+ slices.SortFunc(out, domain.CompareIssueEvents)
182- if c := a.CreatedAt.Compare(b.CreatedAt); c != 0 {
183- return c
184- }
185- if a.Issue < b.Issue {
186- return -1
187- }
188- if a.Issue > b.Issue {
189- return 1
190- }
191- if a.ID < b.ID {
192- return -1
193- }
194- if a.ID > b.ID {
195- return 1
196- }
197- return 0
198- })
199 if len(out) > MaxIssueEvents {182 if len(out) > MaxIssueEvents {
200 out = out[:MaxIssueEvents]183 out = out[:MaxIssueEvents]
201 }184 }
M internal/domain/issue.go +13 -0
@@ -3,6 +3,7 @@
33 package domain
44
55 import (
6+ "cmp"
67 "fmt"
78 "time"
89 )
@@ -139,3 +140,15 @@ type IssueEvent struct {
139140 Actor string
140141 CreatedAt time.Time
141142 }
143+
144+// CompareIssueEvents orders events by time, then issue number, then id. It
145+// suits slices.SortFunc.
146+func CompareIssueEvents(a, b IssueEvent) int {
147+ if c := a.CreatedAt.Compare(b.CreatedAt); c != 0 {
148+ return c
149+ }
150+ if c := cmp.Compare(a.Issue, b.Issue); c != 0 {
151+ return c
152+ }
153+ return cmp.Compare(a.ID, b.ID)
154+}
@@ -3,6 +3,7 @@
3 package domain3 package domain
4 4
5 import (5 import (
6+ "cmp"
6 "fmt"7 "fmt"
7 "time"8 "time"
8 )9 )
@@ -139,3 +140,15 @@ type IssueEvent struct {
139 Actor string140 Actor string
140 CreatedAt time.Time141 CreatedAt time.Time
141 }142 }
143+
144+// CompareIssueEvents orders events by time, then issue number, then id. It
145+// suits slices.SortFunc.
146+func CompareIssueEvents(a, b IssueEvent) int {
147+ if c := a.CreatedAt.Compare(b.CreatedAt); c != 0 {
148+ return c
149+ }
150+ if c := cmp.Compare(a.Issue, b.Issue); c != 0 {
151+ return c
152+ }
153+ return cmp.Compare(a.ID, b.ID)
154+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 45

↑↓ moveenter openesc close