v0.14.0 76d1892

history.sql.go RawHistoryFolder

1// Code generated by sqlc. DO NOT EDIT.
2// versions:
3//   sqlc v1.30.0
4// source: history.sql
5
6package db
7
8import (
9	"context"
10	"database/sql"
11)
12
13const AddOrUpdateHistory = `-- name: AddOrUpdateHistory :exec
14INSERT INTO history (url, title) 
15VALUES (?, ?)
16ON CONFLICT(url) 
17DO UPDATE SET 
18    visit_count = visit_count + 1,
19    last_visited = CURRENT_TIMESTAMP,
20    title = EXCLUDED.title
21`
22
23func (q *Queries) AddOrUpdateHistory(ctx context.Context, url string, title sql.NullString) error {
24	_, err := q.db.ExecContext(ctx, AddOrUpdateHistory, url, title)
25	return err
26}
27
28const DeleteHistory = `-- name: DeleteHistory :exec
29DELETE FROM history
30WHERE id = ?
31`
32
33func (q *Queries) DeleteHistory(ctx context.Context, id int64) error {
34	_, err := q.db.ExecContext(ctx, DeleteHistory, id)
35	return err
36}
37
38const GetHistory = `-- name: GetHistory :many
39SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
40FROM history
41ORDER BY last_visited DESC
42LIMIT ?
43`
44
45func (q *Queries) GetHistory(ctx context.Context, limit int64) ([]History, error) {
46	rows, err := q.db.QueryContext(ctx, GetHistory, limit)
47	if err != nil {
48		return nil, err
49	}
50	defer rows.Close()
51	items := []History{}
52	for rows.Next() {
53		var i History
54		if err := rows.Scan(
55			&i.ID,
56			&i.Url,
57			&i.Title,
58			&i.VisitCount,
59			&i.LastVisited,
60			&i.CreatedAt,
61			&i.FaviconUrl,
62		); err != nil {
63			return nil, err
64		}
65		items = append(items, i)
66	}
67	if err := rows.Close(); err != nil {
68		return nil, err
69	}
70	if err := rows.Err(); err != nil {
71		return nil, err
72	}
73	return items, nil
74}
75
76const GetHistoryEntry = `-- name: GetHistoryEntry :one
77SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
78FROM history
79WHERE url = ?
80LIMIT 1
81`
82
83func (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
98const GetHistoryWithOffset = `-- name: GetHistoryWithOffset :many
99SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
100FROM history
101ORDER BY last_visited DESC
102LIMIT ? OFFSET ?
103`
104
105func (q *Queries) GetHistoryWithOffset(ctx context.Context, limit int64, offset int64) ([]History, error) {
106	rows, err := q.db.QueryContext(ctx, GetHistoryWithOffset, limit, offset)
107	if err != nil {
108		return nil, err
109	}
110	defer rows.Close()
111	items := []History{}
112	for rows.Next() {
113		var i History
114		if err := rows.Scan(
115			&i.ID,
116			&i.Url,
117			&i.Title,
118			&i.VisitCount,
119			&i.LastVisited,
120			&i.CreatedAt,
121			&i.FaviconUrl,
122		); err != nil {
123			return nil, err
124		}
125		items = append(items, i)
126	}
127	if err := rows.Close(); err != nil {
128		return nil, err
129	}
130	if err := rows.Err(); err != nil {
131		return nil, err
132	}
133	return items, nil
134}
135
136const SearchHistory = `-- name: SearchHistory :many
137SELECT id, url, title, visit_count, last_visited, created_at, favicon_url
138FROM history 
139WHERE url LIKE '%' || ? || '%' OR title LIKE '%' || ? || '%'
140ORDER BY visit_count DESC, last_visited DESC
141LIMIT ?
142`
143
144func (q *Queries) SearchHistory(ctx context.Context, column1 sql.NullString, column2 sql.NullString, limit int64) ([]History, error) {
145	rows, err := q.db.QueryContext(ctx, SearchHistory, column1, column2, limit)
146	if err != nil {
147		return nil, err
148	}
149	defer rows.Close()
150	items := []History{}
151	for rows.Next() {
152		var i History
153		if err := rows.Scan(
154			&i.ID,
155			&i.Url,
156			&i.Title,
157			&i.VisitCount,
158			&i.LastVisited,
159			&i.CreatedAt,
160			&i.FaviconUrl,
161		); err != nil {
162			return nil, err
163		}
164		items = append(items, i)
165	}
166	if err := rows.Close(); err != nil {
167		return nil, err
168	}
169	if err := rows.Err(); err != nil {
170		return nil, err
171	}
172	return items, nil
173}
174
175const UpdateHistoryFavicon = `-- name: UpdateHistoryFavicon :exec
176UPDATE history
177SET favicon_url = ?
178WHERE url = ?
179`
180
181func (q *Queries) UpdateHistoryFavicon(ctx context.Context, faviconUrl sql.NullString, url string) error {
182	_, err := q.db.ExecContext(ctx, UpdateHistoryFavicon, faviconUrl, url)
183	return err
184}

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