v0.27.2 5960dd8

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 sqlc
7
8import (
9	"context"
10	"database/sql"
11)
12
13const CapVisitCount = `-- name: CapVisitCount :exec
14UPDATE history SET visit_count = ? WHERE url = ? AND visit_count > ?
15`
16
17type CapVisitCountParams struct {
18	VisitCount   sql.NullInt64 `json:"visit_count"`
19	Url          string        `json:"url"`
20	VisitCount_2 sql.NullInt64 `json:"visit_count_2"`
21}
22
23func (q *Queries) CapVisitCount(ctx context.Context, arg CapVisitCountParams) error {
24	_, err := q.db.ExecContext(ctx, CapVisitCount, arg.VisitCount, arg.Url, arg.VisitCount_2)
25	return err
26}
27
28const DeleteAllHistory = `-- name: DeleteAllHistory :exec
29DELETE FROM history
30`
31
32func (q *Queries) DeleteAllHistory(ctx context.Context) error {
33	_, err := q.db.ExecContext(ctx, DeleteAllHistory)
34	return err
35}
36
37const DeleteHistoryByDomain = `-- name: DeleteHistoryByDomain :exec
38DELETE FROM history WHERE url LIKE '%://' || ? || '/%' OR url LIKE '%://' || ? || '?%' OR url LIKE '%://' || ? || '#%' OR url LIKE '%://' || ?
39`
40
41type DeleteHistoryByDomainParams struct {
42	Column1 sql.NullString `json:"column_1"`
43	Column2 sql.NullString `json:"column_2"`
44	Column3 sql.NullString `json:"column_3"`
45	Column4 sql.NullString `json:"column_4"`
46}
47
48func (q *Queries) DeleteHistoryByDomain(ctx context.Context, arg DeleteHistoryByDomainParams) error {
49	_, err := q.db.ExecContext(ctx, DeleteHistoryByDomain,
50		arg.Column1,
51		arg.Column2,
52		arg.Column3,
53		arg.Column4,
54	)
55	return err
56}
57
58const DeleteHistoryByID = `-- name: DeleteHistoryByID :exec
59DELETE FROM history WHERE id = ?
60`
61
62func (q *Queries) DeleteHistoryByID(ctx context.Context, id int64) error {
63	_, err := q.db.ExecContext(ctx, DeleteHistoryByID, id)
64	return err
65}
66
67const DeleteHistoryOlderThan = `-- name: DeleteHistoryOlderThan :exec
68DELETE FROM history WHERE last_visited < ?
69`
70
71func (q *Queries) DeleteHistoryOlderThan(ctx context.Context, lastVisited sql.NullTime) error {
72	_, err := q.db.ExecContext(ctx, DeleteHistoryOlderThan, lastVisited)
73	return err
74}
75
76const GetAllMostVisited = `-- name: GetAllMostVisited :many
77SELECT id, url, title, favicon_url, visit_count, last_visited, created_at FROM history
78ORDER BY visit_count DESC, last_visited DESC
79`
80
81func (q *Queries) GetAllMostVisited(ctx context.Context) ([]History, error) {
82	rows, err := q.db.QueryContext(ctx, GetAllMostVisited)
83	if err != nil {
84		return nil, err
85	}
86	defer rows.Close()
87	items := []History{}
88	for rows.Next() {
89		var i History
90		if err := rows.Scan(
91			&i.ID,
92			&i.Url,
93			&i.Title,
94			&i.FaviconUrl,
95			&i.VisitCount,
96			&i.LastVisited,
97			&i.CreatedAt,
98		); err != nil {
99			return nil, err
100		}
101		items = append(items, i)
102	}
103	if err := rows.Close(); err != nil {
104		return nil, err
105	}
106	if err := rows.Err(); err != nil {
107		return nil, err
108	}
109	return items, nil
110}
111
112const GetAllRecentHistory = `-- name: GetAllRecentHistory :many
113SELECT id, url, title, favicon_url, visit_count, last_visited, created_at FROM history
114ORDER BY last_visited DESC
115`
116
117func (q *Queries) GetAllRecentHistory(ctx context.Context) ([]History, error) {
118	rows, err := q.db.QueryContext(ctx, GetAllRecentHistory)
119	if err != nil {
120		return nil, err
121	}
122	defer rows.Close()
123	items := []History{}
124	for rows.Next() {
125		var i History
126		if err := rows.Scan(
127			&i.ID,
128			&i.Url,
129			&i.Title,
130			&i.FaviconUrl,
131			&i.VisitCount,
132			&i.LastVisited,
133			&i.CreatedAt,
134		); err != nil {
135			return nil, err
136		}
137		items = append(items, i)
138	}
139	if err := rows.Close(); err != nil {
140		return nil, err
141	}
142	if err := rows.Err(); err != nil {
143		return nil, err
144	}
145	return items, nil
146}
147
148const GetDailyVisitCount = `-- name: GetDailyVisitCount :many
149SELECT date(last_visited) as day, COUNT(*) as entries, SUM(visit_count) as visits FROM history WHERE last_visited >= date('now', ?) GROUP BY day ORDER BY day ASC
150`
151
152type GetDailyVisitCountRow struct {
153	Day     interface{}     `json:"day"`
154	Entries int64           `json:"entries"`
155	Visits  sql.NullFloat64 `json:"visits"`
156}
157
158func (q *Queries) GetDailyVisitCount(ctx context.Context, date interface{}) ([]GetDailyVisitCountRow, error) {
159	rows, err := q.db.QueryContext(ctx, GetDailyVisitCount, date)
160	if err != nil {
161		return nil, err
162	}
163	defer rows.Close()
164	items := []GetDailyVisitCountRow{}
165	for rows.Next() {
166		var i GetDailyVisitCountRow
167		if err := rows.Scan(&i.Day, &i.Entries, &i.Visits); err != nil {
168			return nil, err
169		}
170		items = append(items, i)
171	}
172	if err := rows.Close(); err != nil {
173		return nil, err
174	}
175	if err := rows.Err(); err != nil {
176		return nil, err
177	}
178	return items, nil
179}
180
181const GetDomainStats = `-- name: GetDomainStats :many
182SELECT SUBSTR(SUBSTR(url, INSTR(url, '://') + 3), 1, CASE WHEN INSTR(SUBSTR(url, INSTR(url, '://') + 3), '/') > 0 THEN INSTR(SUBSTR(url, INSTR(url, '://') + 3), '/') - 1 ELSE LENGTH(SUBSTR(url, INSTR(url, '://') + 3)) END) as domain, COUNT(*) as page_count, SUM(visit_count) as total_visits, MAX(last_visited) as last_visit FROM history GROUP BY domain ORDER BY total_visits DESC LIMIT ?
183`
184
185type GetDomainStatsRow struct {
186	Domain      string          `json:"domain"`
187	PageCount   int64           `json:"page_count"`
188	TotalVisits sql.NullFloat64 `json:"total_visits"`
189	LastVisit   interface{}     `json:"last_visit"`
190}
191
192func (q *Queries) GetDomainStats(ctx context.Context, limit int64) ([]GetDomainStatsRow, error) {
193	rows, err := q.db.QueryContext(ctx, GetDomainStats, limit)
194	if err != nil {
195		return nil, err
196	}
197	defer rows.Close()
198	items := []GetDomainStatsRow{}
199	for rows.Next() {
200		var i GetDomainStatsRow
201		if err := rows.Scan(
202			&i.Domain,
203			&i.PageCount,
204			&i.TotalVisits,
205			&i.LastVisit,
206		); err != nil {
207			return nil, err
208		}
209		items = append(items, i)
210	}
211	if err := rows.Close(); err != nil {
212		return nil, err
213	}
214	if err := rows.Err(); err != nil {
215		return nil, err
216	}
217	return items, nil
218}
219
220const GetHistoryByURL = `-- name: GetHistoryByURL :one
221SELECT id, url, title, favicon_url, visit_count, last_visited, created_at FROM history WHERE url = ? LIMIT 1
222`
223
224func (q *Queries) GetHistoryByURL(ctx context.Context, url string) (History, error) {
225	row := q.db.QueryRowContext(ctx, GetHistoryByURL, url)
226	var i History
227	err := row.Scan(
228		&i.ID,
229		&i.Url,
230		&i.Title,
231		&i.FaviconUrl,
232		&i.VisitCount,
233		&i.LastVisited,
234		&i.CreatedAt,
235	)
236	return i, err
237}
238
239const GetHistoryStats = `-- name: GetHistoryStats :one
240SELECT COUNT(*) as total_entries, COALESCE(SUM(visit_count), 0) as total_visits, COUNT(DISTINCT date(last_visited)) as unique_days FROM history
241`
242
243type GetHistoryStatsRow struct {
244	TotalEntries int64       `json:"total_entries"`
245	TotalVisits  interface{} `json:"total_visits"`
246	UniqueDays   int64       `json:"unique_days"`
247}
248
249func (q *Queries) GetHistoryStats(ctx context.Context) (GetHistoryStatsRow, error) {
250	row := q.db.QueryRowContext(ctx, GetHistoryStats)
251	var i GetHistoryStatsRow
252	err := row.Scan(&i.TotalEntries, &i.TotalVisits, &i.UniqueDays)
253	return i, err
254}
255
256const GetHourlyDistribution = `-- name: GetHourlyDistribution :many
257SELECT CAST(strftime('%H', last_visited) AS INTEGER) as hour, COUNT(*) as visit_count FROM history GROUP BY hour ORDER BY hour
258`
259
260type GetHourlyDistributionRow struct {
261	Hour       int64 `json:"hour"`
262	VisitCount int64 `json:"visit_count"`
263}
264
265func (q *Queries) GetHourlyDistribution(ctx context.Context) ([]GetHourlyDistributionRow, error) {
266	rows, err := q.db.QueryContext(ctx, GetHourlyDistribution)
267	if err != nil {
268		return nil, err
269	}
270	defer rows.Close()
271	items := []GetHourlyDistributionRow{}
272	for rows.Next() {
273		var i GetHourlyDistributionRow
274		if err := rows.Scan(&i.Hour, &i.VisitCount); err != nil {
275			return nil, err
276		}
277		items = append(items, i)
278	}
279	if err := rows.Close(); err != nil {
280		return nil, err
281	}
282	if err := rows.Err(); err != nil {
283		return nil, err
284	}
285	return items, nil
286}
287
288const GetMostVisited = `-- name: GetMostVisited :many
289SELECT id, url, title, favicon_url, visit_count, last_visited, created_at FROM history
290WHERE last_visited >= datetime('now', ?)
291ORDER BY visit_count DESC, last_visited DESC
292`
293
294func (q *Queries) GetMostVisited(ctx context.Context, datetime interface{}) ([]History, error) {
295	rows, err := q.db.QueryContext(ctx, GetMostVisited, datetime)
296	if err != nil {
297		return nil, err
298	}
299	defer rows.Close()
300	items := []History{}
301	for rows.Next() {
302		var i History
303		if err := rows.Scan(
304			&i.ID,
305			&i.Url,
306			&i.Title,
307			&i.FaviconUrl,
308			&i.VisitCount,
309			&i.LastVisited,
310			&i.CreatedAt,
311		); err != nil {
312			return nil, err
313		}
314		items = append(items, i)
315	}
316	if err := rows.Close(); err != nil {
317		return nil, err
318	}
319	if err := rows.Err(); err != nil {
320		return nil, err
321	}
322	return items, nil
323}
324
325const GetRecentHistory = `-- name: GetRecentHistory :many
326SELECT id, url, title, favicon_url, visit_count, last_visited, created_at FROM history ORDER BY last_visited DESC LIMIT ? OFFSET ?
327`
328
329type GetRecentHistoryParams struct {
330	Limit  int64 `json:"limit"`
331	Offset int64 `json:"offset"`
332}
333
334func (q *Queries) GetRecentHistory(ctx context.Context, arg GetRecentHistoryParams) ([]History, error) {
335	rows, err := q.db.QueryContext(ctx, GetRecentHistory, arg.Limit, arg.Offset)
336	if err != nil {
337		return nil, err
338	}
339	defer rows.Close()
340	items := []History{}
341	for rows.Next() {
342		var i History
343		if err := rows.Scan(
344			&i.ID,
345			&i.Url,
346			&i.Title,
347			&i.FaviconUrl,
348			&i.VisitCount,
349			&i.LastVisited,
350			&i.CreatedAt,
351		); err != nil {
352			return nil, err
353		}
354		items = append(items, i)
355	}
356	if err := rows.Close(); err != nil {
357		return nil, err
358	}
359	if err := rows.Err(); err != nil {
360		return nil, err
361	}
362	return items, nil
363}
364
365const GetRecentHistorySince = `-- name: GetRecentHistorySince :many
366SELECT id, url, title, favicon_url, visit_count, last_visited, created_at FROM history
367WHERE last_visited >= datetime('now', ?)
368ORDER BY last_visited DESC
369`
370
371func (q *Queries) GetRecentHistorySince(ctx context.Context, datetime interface{}) ([]History, error) {
372	rows, err := q.db.QueryContext(ctx, GetRecentHistorySince, datetime)
373	if err != nil {
374		return nil, err
375	}
376	defer rows.Close()
377	items := []History{}
378	for rows.Next() {
379		var i History
380		if err := rows.Scan(
381			&i.ID,
382			&i.Url,
383			&i.Title,
384			&i.FaviconUrl,
385			&i.VisitCount,
386			&i.LastVisited,
387			&i.CreatedAt,
388		); err != nil {
389			return nil, err
390		}
391		items = append(items, i)
392	}
393	if err := rows.Close(); err != nil {
394		return nil, err
395	}
396	if err := rows.Err(); err != nil {
397		return nil, err
398	}
399	return items, nil
400}
401
402const IncrementVisitCount = `-- name: IncrementVisitCount :exec
403UPDATE history
404SET visit_count = visit_count + 1, last_visited = CURRENT_TIMESTAMP
405WHERE url = ?
406`
407
408func (q *Queries) IncrementVisitCount(ctx context.Context, url string) error {
409	_, err := q.db.ExecContext(ctx, IncrementVisitCount, url)
410	return err
411}
412
413const IncrementVisitCountByDelta = `-- name: IncrementVisitCountByDelta :exec
414UPDATE history
415SET visit_count = visit_count + ?, last_visited = CURRENT_TIMESTAMP
416WHERE url = ?
417`
418
419type IncrementVisitCountByDeltaParams struct {
420	VisitCount sql.NullInt64 `json:"visit_count"`
421	Url        string        `json:"url"`
422}
423
424func (q *Queries) IncrementVisitCountByDelta(ctx context.Context, arg IncrementVisitCountByDeltaParams) error {
425	_, err := q.db.ExecContext(ctx, IncrementVisitCountByDelta, arg.VisitCount, arg.Url)
426	return err
427}
428
429const SearchHistory = `-- name: SearchHistory :many
430SELECT id, url, title, favicon_url, visit_count, last_visited, created_at FROM history
431WHERE url LIKE '%' || ? || '%' OR title LIKE '%' || ? || '%'
432ORDER BY visit_count DESC, last_visited DESC
433LIMIT ?
434`
435
436type SearchHistoryParams struct {
437	Column1 sql.NullString `json:"column_1"`
438	Column2 sql.NullString `json:"column_2"`
439	Limit   int64          `json:"limit"`
440}
441
442func (q *Queries) SearchHistory(ctx context.Context, arg SearchHistoryParams) ([]History, error) {
443	rows, err := q.db.QueryContext(ctx, SearchHistory, arg.Column1, arg.Column2, arg.Limit)
444	if err != nil {
445		return nil, err
446	}
447	defer rows.Close()
448	items := []History{}
449	for rows.Next() {
450		var i History
451		if err := rows.Scan(
452			&i.ID,
453			&i.Url,
454			&i.Title,
455			&i.FaviconUrl,
456			&i.VisitCount,
457			&i.LastVisited,
458			&i.CreatedAt,
459		); err != nil {
460			return nil, err
461		}
462		items = append(items, i)
463	}
464	if err := rows.Close(); err != nil {
465		return nil, err
466	}
467	if err := rows.Err(); err != nil {
468		return nil, err
469	}
470	return items, nil
471}
472
473const SearchHistoryFTSTitle = `-- name: SearchHistoryFTSTitle :many
474SELECT h.id, h.url, h.title, h.favicon_url, h.visit_count, h.last_visited, h.created_at
475FROM history_fts fts
476JOIN history h ON fts.rowid = h.id
477WHERE fts.title MATCH ?1
478ORDER BY h.visit_count DESC, h.last_visited DESC
479LIMIT ?2
480`
481
482type SearchHistoryFTSTitleParams struct {
483	Query string `json:"query"`
484	Limit int64  `json:"limit"`
485}
486
487func (q *Queries) SearchHistoryFTSTitle(ctx context.Context, arg SearchHistoryFTSTitleParams) ([]History, error) {
488	rows, err := q.db.QueryContext(ctx, SearchHistoryFTSTitle, arg.Query, arg.Limit)
489	if err != nil {
490		return nil, err
491	}
492	defer rows.Close()
493	items := []History{}
494	for rows.Next() {
495		var i History
496		if err := rows.Scan(
497			&i.ID,
498			&i.Url,
499			&i.Title,
500			&i.FaviconUrl,
501			&i.VisitCount,
502			&i.LastVisited,
503			&i.CreatedAt,
504		); err != nil {
505			return nil, err
506		}
507		items = append(items, i)
508	}
509	if err := rows.Close(); err != nil {
510		return nil, err
511	}
512	if err := rows.Err(); err != nil {
513		return nil, err
514	}
515	return items, nil
516}
517
518const SearchHistoryFTSUrl = `-- name: SearchHistoryFTSUrl :many
519SELECT h.id, h.url, h.title, h.favicon_url, h.visit_count, h.last_visited, h.created_at
520FROM history_fts fts
521JOIN history h ON fts.rowid = h.id
522WHERE fts.url MATCH ?1
523ORDER BY h.visit_count DESC, h.last_visited DESC
524LIMIT ?2
525`
526
527type SearchHistoryFTSUrlParams struct {
528	Query string `json:"query"`
529	Limit int64  `json:"limit"`
530}
531
532func (q *Queries) SearchHistoryFTSUrl(ctx context.Context, arg SearchHistoryFTSUrlParams) ([]History, error) {
533	rows, err := q.db.QueryContext(ctx, SearchHistoryFTSUrl, arg.Query, arg.Limit)
534	if err != nil {
535		return nil, err
536	}
537	defer rows.Close()
538	items := []History{}
539	for rows.Next() {
540		var i History
541		if err := rows.Scan(
542			&i.ID,
543			&i.Url,
544			&i.Title,
545			&i.FaviconUrl,
546			&i.VisitCount,
547			&i.LastVisited,
548			&i.CreatedAt,
549		); err != nil {
550			return nil, err
551		}
552		items = append(items, i)
553	}
554	if err := rows.Close(); err != nil {
555		return nil, err
556	}
557	if err := rows.Err(); err != nil {
558		return nil, err
559	}
560	return items, nil
561}
562
563const SearchHistoryFTSUrlWithDomainBoost = `-- name: SearchHistoryFTSUrlWithDomainBoost :many
564SELECT h.id, h.url, h.title, h.favicon_url, h.visit_count, h.last_visited, h.created_at,
565       CASE
566           WHEN h.url LIKE '%://' || ?1 || '.%' THEN 2
567           WHEN h.url LIKE '%://%.' || ?1 || '.%' THEN 2
568           WHEN h.url LIKE '%://' || ?1 || '/%' THEN 2
569           WHEN h.url LIKE '%://%.' || ?1 || '/%' THEN 1
570           ELSE 0
571       END as domain_boost
572FROM history_fts fts
573JOIN history h ON fts.rowid = h.id
574WHERE fts.url MATCH ?2
575ORDER BY domain_boost DESC, h.visit_count DESC, h.last_visited DESC
576LIMIT ?3
577`
578
579type SearchHistoryFTSUrlWithDomainBoostParams struct {
580	Term  sql.NullString `json:"term"`
581	Query string         `json:"query"`
582	Limit int64          `json:"limit"`
583}
584
585type SearchHistoryFTSUrlWithDomainBoostRow struct {
586	ID          int64          `json:"id"`
587	Url         string         `json:"url"`
588	Title       sql.NullString `json:"title"`
589	FaviconUrl  sql.NullString `json:"favicon_url"`
590	VisitCount  sql.NullInt64  `json:"visit_count"`
591	LastVisited sql.NullTime   `json:"last_visited"`
592	CreatedAt   sql.NullTime   `json:"created_at"`
593	DomainBoost int64          `json:"domain_boost"`
594}
595
596func (q *Queries) SearchHistoryFTSUrlWithDomainBoost(ctx context.Context, arg SearchHistoryFTSUrlWithDomainBoostParams) ([]SearchHistoryFTSUrlWithDomainBoostRow, error) {
597	rows, err := q.db.QueryContext(ctx, SearchHistoryFTSUrlWithDomainBoost, arg.Term, arg.Query, arg.Limit)
598	if err != nil {
599		return nil, err
600	}
601	defer rows.Close()
602	items := []SearchHistoryFTSUrlWithDomainBoostRow{}
603	for rows.Next() {
604		var i SearchHistoryFTSUrlWithDomainBoostRow
605		if err := rows.Scan(
606			&i.ID,
607			&i.Url,
608			&i.Title,
609			&i.FaviconUrl,
610			&i.VisitCount,
611			&i.LastVisited,
612			&i.CreatedAt,
613			&i.DomainBoost,
614		); err != nil {
615			return nil, err
616		}
617		items = append(items, i)
618	}
619	if err := rows.Close(); err != nil {
620		return nil, err
621	}
622	if err := rows.Err(); err != nil {
623		return nil, err
624	}
625	return items, nil
626}
627
628const UpsertHistory = `-- name: UpsertHistory :exec
629INSERT INTO history (url, title, favicon_url)
630VALUES (?, ?, ?)
631ON CONFLICT(url)
632DO UPDATE SET
633    visit_count = visit_count + 1,
634    last_visited = CURRENT_TIMESTAMP,
635    title = COALESCE(EXCLUDED.title, history.title),
636    favicon_url = COALESCE(EXCLUDED.favicon_url, history.favicon_url)
637`
638
639type UpsertHistoryParams struct {
640	Url        string         `json:"url"`
641	Title      sql.NullString `json:"title"`
642	FaviconUrl sql.NullString `json:"favicon_url"`
643}
644
645func (q *Queries) UpsertHistory(ctx context.Context, arg UpsertHistoryParams) error {
646	_, err := q.db.ExecContext(ctx, UpsertHistory, arg.Url, arg.Title, arg.FaviconUrl)
647	return err
648}

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