detached 551b57d

feat(db): add DeleteAllHistory query for batch history removal

commit
551b57d02c507fbddcef5d555192b553c02bb3a9
author
bnema · · 2025-11-19 18:24 UTC
parent
696087a
signature
GPG Unverified2B82207D370127A0 The key is unknown
4 files · +14 -0
M internal/db/history.sql.go +9 -0
@@ -25,6 +25,15 @@ func (q *Queries) AddOrUpdateHistory(ctx context.Context, url string, title sql.
2525 return err
2626 }
2727
28+const DeleteAllHistory = `-- name: DeleteAllHistory :exec
29+DELETE FROM history
30+`
31+
32+func (q *Queries) DeleteAllHistory(ctx context.Context) error {
33+ _, err := q.db.ExecContext(ctx, DeleteAllHistory)
34+ return err
35+}
36+
2837 const DeleteHistory = `-- name: DeleteHistory :exec
2938 DELETE FROM history
3039 WHERE id = ?
@@ -25,6 +25,15 @@ func (q *Queries) AddOrUpdateHistory(ctx context.Context, url string, title sql.
25 return err25 return err
26 }26 }
27 27
28+const DeleteAllHistory = `-- name: DeleteAllHistory :exec
29+DELETE FROM history
30+`
31+
32+func (q *Queries) DeleteAllHistory(ctx context.Context) error {
33+ _, err := q.db.ExecContext(ctx, DeleteAllHistory)
34+ return err
35+}
36+
28 const DeleteHistory = `-- name: DeleteHistory :exec37 const DeleteHistory = `-- name: DeleteHistory :exec
29 DELETE FROM history38 DELETE FROM history
30 WHERE id = ?39 WHERE id = ?
M internal/db/interfaces.go +1 -0
@@ -25,6 +25,7 @@ type HistoryQuerier interface {
2525 AddOrUpdateHistory(ctx context.Context, url string, title sql.NullString) error
2626 UpdateHistoryFavicon(ctx context.Context, faviconUrl sql.NullString, url string) error
2727 DeleteHistory(ctx context.Context, id int64) error
28+ DeleteAllHistory(ctx context.Context) error
2829 }
2930
3031 // CertificateQuerier defines the interface for certificate validation-related database operations
@@ -25,6 +25,7 @@ type HistoryQuerier interface {
25 AddOrUpdateHistory(ctx context.Context, url string, title sql.NullString) error25 AddOrUpdateHistory(ctx context.Context, url string, title sql.NullString) error
26 UpdateHistoryFavicon(ctx context.Context, faviconUrl sql.NullString, url string) error26 UpdateHistoryFavicon(ctx context.Context, faviconUrl sql.NullString, url string) error
27 DeleteHistory(ctx context.Context, id int64) error27 DeleteHistory(ctx context.Context, id int64) error
28+ DeleteAllHistory(ctx context.Context) error
28 }29 }
29 30
30 // CertificateQuerier defines the interface for certificate validation-related database operations31 // CertificateQuerier defines the interface for certificate validation-related database operations
M internal/db/querier.go +1 -0
@@ -15,6 +15,7 @@ type Querier interface {
1515 CleanupOldZoomLevels(ctx context.Context, dollar_1 sql.NullString) error
1616 // Insert a new favorite with auto-incremented position
1717 CreateFavorite(ctx context.Context, url string, title sql.NullString, faviconUrl sql.NullString) error
18+ DeleteAllHistory(ctx context.Context) error
1819 DeleteCertificateValidation(ctx context.Context, hostname string, certificateHash string) error
1920 DeleteExpiredCertificateValidations(ctx context.Context) error
2021 // Delete a favorite by URL
@@ -15,6 +15,7 @@ type Querier interface {
15 CleanupOldZoomLevels(ctx context.Context, dollar_1 sql.NullString) error15 CleanupOldZoomLevels(ctx context.Context, dollar_1 sql.NullString) error
16 // Insert a new favorite with auto-incremented position16 // Insert a new favorite with auto-incremented position
17 CreateFavorite(ctx context.Context, url string, title sql.NullString, faviconUrl sql.NullString) error17 CreateFavorite(ctx context.Context, url string, title sql.NullString, faviconUrl sql.NullString) error
18+ DeleteAllHistory(ctx context.Context) error
18 DeleteCertificateValidation(ctx context.Context, hostname string, certificateHash string) error19 DeleteCertificateValidation(ctx context.Context, hostname string, certificateHash string) error
19 DeleteExpiredCertificateValidations(ctx context.Context) error20 DeleteExpiredCertificateValidations(ctx context.Context) error
20 // Delete a favorite by URL21 // Delete a favorite by URL
M internal/db/queries/history.sql +3 -0
@@ -41,6 +41,9 @@ LIMIT 1;
4141 DELETE FROM history
4242 WHERE id = ?;
4343
44+-- name: DeleteAllHistory :exec
45+DELETE FROM history;
46+
4447 -- name: GetMostVisited :many
4548 SELECT *
4649 FROM history
@@ -41,6 +41,9 @@ LIMIT 1;
41 DELETE FROM history41 DELETE FROM history
42 WHERE id = ?;42 WHERE id = ?;
43 43
44+-- name: DeleteAllHistory :exec
45+DELETE FROM history;
46+
44 -- name: GetMostVisited :many47 -- name: GetMostVisited :many
45 SELECT *48 SELECT *
46 FROM history49 FROM history

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