detached 1534d2b

feat(db): add GetHistoryEntry query for favicon lookup

commit
1534d2b95b11280625b6fb04f431f0f983719559
author
bamen · · 2025-10-06 16:32 UTC
committer
bamen · · 2025-10-06 18:28 UTC
parent
8c77b69
signature
unsigned
3 files · +31 -2
M internal/db/history.sql.go +23 -1
@@ -73,6 +73,28 @@ func (q *Queries) GetHistory(ctx context.Context, limit int64) ([]History, error
7373 return items, nil
7474 }
7575
76+const GetHistoryEntry = `-- name: GetHistoryEntry :one
77+SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
78+FROM history
79+WHERE url = ?
80+LIMIT 1
81+`
82+
83+func (q *Queries) GetHistoryEntry(ctx context.Context, url string) (History, error) {
84+ row := q.db.QueryRowContext(ctx, GetHistoryEntry, url)
85+ var i History
86+ err := row.Scan(
87+ &i.ID,
88+ &i.Url,
89+ &i.Title,
90+ &i.VisitCount,
91+ &i.LastVisited,
92+ &i.CreatedAt,
93+ &i.FaviconUrl,
94+ )
95+ return i, err
96+}
97+
7698 const GetHistoryWithOffset = `-- name: GetHistoryWithOffset :many
7799 SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
78100 FROM history
@@ -186,7 +208,7 @@ func (q *Queries) SearchHistory(ctx context.Context, column1 sql.NullString, col
186208 }
187209
188210 const UpdateHistoryFavicon = `-- name: UpdateHistoryFavicon :exec
189-UPDATE history
211+UPDATE history
190212 SET favicon_url = ?
191213 WHERE url = ?
192214 `
@@ -73,6 +73,28 @@ func (q *Queries) GetHistory(ctx context.Context, limit int64) ([]History, error
73 return items, nil73 return items, nil
74 }74 }
75 75
76+const GetHistoryEntry = `-- name: GetHistoryEntry :one
77+SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
78+FROM history
79+WHERE url = ?
80+LIMIT 1
81+`
82+
83+func (q *Queries) GetHistoryEntry(ctx context.Context, url string) (History, error) {
84+ row := q.db.QueryRowContext(ctx, GetHistoryEntry, url)
85+ var i History
86+ err := row.Scan(
87+ &i.ID,
88+ &i.Url,
89+ &i.Title,
90+ &i.VisitCount,
91+ &i.LastVisited,
92+ &i.CreatedAt,
93+ &i.FaviconUrl,
94+ )
95+ return i, err
96+}
97+
76 const GetHistoryWithOffset = `-- name: GetHistoryWithOffset :many98 const GetHistoryWithOffset = `-- name: GetHistoryWithOffset :many
77 SELECT id, url, title, visit_count, last_visited, created_at, favicon_url99 SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
78 FROM history100 FROM history
@@ -186,7 +208,7 @@ func (q *Queries) SearchHistory(ctx context.Context, column1 sql.NullString, col
186 }208 }
187 209
188 const UpdateHistoryFavicon = `-- name: UpdateHistoryFavicon :exec210 const UpdateHistoryFavicon = `-- name: UpdateHistoryFavicon :exec
189-UPDATE history 211+UPDATE history
190 SET favicon_url = ?212 SET favicon_url = ?
191 WHERE url = ?213 WHERE url = ?
192 `214 `
M internal/db/querier.go +1 -0
@@ -20,6 +20,7 @@ type Querier interface {
2020 DeleteZoomLevel(ctx context.Context, domain string) error
2121 GetCertificateValidation(ctx context.Context, hostname string, certificateHash string) (CertificateValidation, error)
2222 GetHistory(ctx context.Context, limit int64) ([]History, error)
23+ GetHistoryEntry(ctx context.Context, url string) (History, error)
2324 GetHistoryWithOffset(ctx context.Context, limit int64, offset int64) ([]History, error)
2425 GetShortcuts(ctx context.Context) ([]Shortcut, error)
2526 // Get zoom level for a specific domain
@@ -20,6 +20,7 @@ type Querier interface {
20 DeleteZoomLevel(ctx context.Context, domain string) error20 DeleteZoomLevel(ctx context.Context, domain string) error
21 GetCertificateValidation(ctx context.Context, hostname string, certificateHash string) (CertificateValidation, error)21 GetCertificateValidation(ctx context.Context, hostname string, certificateHash string) (CertificateValidation, error)
22 GetHistory(ctx context.Context, limit int64) ([]History, error)22 GetHistory(ctx context.Context, limit int64) ([]History, error)
23+ GetHistoryEntry(ctx context.Context, url string) (History, error)
23 GetHistoryWithOffset(ctx context.Context, limit int64, offset int64) ([]History, error)24 GetHistoryWithOffset(ctx context.Context, limit int64, offset int64) ([]History, error)
24 GetShortcuts(ctx context.Context) ([]Shortcut, error)25 GetShortcuts(ctx context.Context) ([]Shortcut, error)
25 // Get zoom level for a specific domain26 // Get zoom level for a specific domain
M internal/db/queries/history.sql +7 -1
@@ -27,10 +27,16 @@ ORDER BY visit_count DESC, last_visited DESC
2727 LIMIT ?;
2828
2929 -- name: UpdateHistoryFavicon :exec
30-UPDATE history
30+UPDATE history
3131 SET favicon_url = ?
3232 WHERE url = ?;
3333
34+-- name: GetHistoryEntry :one
35+SELECT *
36+FROM history
37+WHERE url = ?
38+LIMIT 1;
39+
3440 -- name: DeleteHistory :exec
3541 DELETE FROM history
3642 WHERE id = ?;
@@ -27,10 +27,16 @@ ORDER BY visit_count DESC, last_visited DESC
27 LIMIT ?;27 LIMIT ?;
28 28
29 -- name: UpdateHistoryFavicon :exec29 -- name: UpdateHistoryFavicon :exec
30-UPDATE history 30+UPDATE history
31 SET favicon_url = ?31 SET favicon_url = ?
32 WHERE url = ?;32 WHERE url = ?;
33 33
34+-- name: GetHistoryEntry :one
35+SELECT *
36+FROM history
37+WHERE url = ?
38+LIMIT 1;
39+
34 -- name: DeleteHistory :exec40 -- name: DeleteHistory :exec
35 DELETE FROM history41 DELETE FROM history
36 WHERE id = ?;42 WHERE id = ?;

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