history_repo_rank_test.go RawHistoryFolder

1package sqlite
2
3import (
4	"testing"
5	"time"
6
7	"github.com/bnema/dumber/internal/domain/entity"
8)
9
10func TestSortRankedHistoryMatches(t *testing.T) {
11	now := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC)
12	older := now.Add(-24 * time.Hour)
13
14	items := []rankedHistoryMatch{
15		{
16			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 1, URL: "z-url", VisitCount: 5, LastVisited: now}, Score: 10},
17			score:         10,
18			exactURLMatch: false,
19			prefixURL:     false,
20			urlMatch:      false,
21			prefixTitle:   false,
22		},
23		{
24			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 2, URL: "a-url", VisitCount: 5, LastVisited: now}, Score: 20},
25			score:         20,
26			exactURLMatch: false,
27			prefixURL:     false,
28			urlMatch:      false,
29			prefixTitle:   false,
30		},
31		{
32			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 3, URL: "b-url", VisitCount: 5, LastVisited: now}, Score: 10},
33			score:         10,
34			exactURLMatch: true,
35			prefixURL:     false,
36			urlMatch:      false,
37			prefixTitle:   false,
38		},
39		{
40			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 4, URL: "c-url", VisitCount: 5, LastVisited: now}, Score: 10},
41			score:         10,
42			exactURLMatch: false,
43			prefixURL:     true,
44			urlMatch:      false,
45			prefixTitle:   false,
46		},
47		{
48			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 5, URL: "d-url", VisitCount: 5, LastVisited: now}, Score: 10},
49			score:         10,
50			exactURLMatch: false,
51			prefixURL:     false,
52			urlMatch:      true,
53			prefixTitle:   false,
54		},
55		{
56			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 6, URL: "e-url", VisitCount: 5, LastVisited: now}, Score: 10},
57			score:         10,
58			exactURLMatch: false,
59			prefixURL:     false,
60			urlMatch:      false,
61			prefixTitle:   true,
62		},
63		{
64			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 7, URL: "f-url", VisitCount: 10, LastVisited: now}, Score: 10},
65			score:         10,
66			exactURLMatch: false,
67			prefixURL:     false,
68			urlMatch:      false,
69			prefixTitle:   false,
70		},
71		{
72			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 8, URL: "g-url", VisitCount: 5, LastVisited: now}, Score: 10},
73			score:         10,
74			exactURLMatch: false,
75			prefixURL:     false,
76			urlMatch:      false,
77			prefixTitle:   false,
78		},
79		{
80			match:         entity.HistoryMatch{Entry: &entity.HistoryEntry{ID: 9, URL: "h-url", VisitCount: 5, LastVisited: older}, Score: 10},
81			score:         10,
82			exactURLMatch: false,
83			prefixURL:     false,
84			urlMatch:      false,
85			prefixTitle:   false,
86		},
87	}
88
89	sortRankedHistoryMatches(items)
90
91	wantOrder := []int64{2, 3, 4, 5, 6, 7, 8, 1, 9}
92	for i, want := range wantOrder {
93		got := items[i].match.Entry.ID
94		if got != want {
95			t.Errorf("position %d: want ID %d, got ID %d", i, want, got)
96		}
97	}
98}

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 8

Tags 42

↑↓ moveenter openesc close