v0.33.1 9577fee

sessions.sql.go RawHistoryFolder

1// Code generated by sqlc. DO NOT EDIT.
2// versions:
3//   sqlc v1.30.0
4// source: sessions.sql
5
6package sqlc
7
8import (
9	"context"
10	"database/sql"
11	"time"
12)
13
14const DeleteExitedSessionsBefore = `-- name: DeleteExitedSessionsBefore :execrows
15DELETE FROM sessions
16WHERE type = 'browser'
17  AND ended_at IS NOT NULL
18  AND ended_at < ?
19`
20
21// Deletes exited browser sessions older than the given cutoff time.
22func (q *Queries) DeleteExitedSessionsBefore(ctx context.Context, endedAt sql.NullTime) (int64, error) {
23	result, err := q.db.ExecContext(ctx, DeleteExitedSessionsBefore, endedAt)
24	if err != nil {
25		return 0, err
26	}
27	return result.RowsAffected()
28}
29
30const DeleteOldestExitedSessions = `-- name: DeleteOldestExitedSessions :execrows
31DELETE FROM sessions
32WHERE id IN (
33    SELECT id FROM sessions
34    WHERE type = 'browser' AND ended_at IS NOT NULL
35    ORDER BY ended_at DESC
36    LIMIT -1 OFFSET ?
37)
38`
39
40// Deletes exited browser sessions beyond the keep limit, keeping the most recent ones.
41func (q *Queries) DeleteOldestExitedSessions(ctx context.Context, offset int64) (int64, error) {
42	result, err := q.db.ExecContext(ctx, DeleteOldestExitedSessions, offset)
43	if err != nil {
44		return 0, err
45	}
46	return result.RowsAffected()
47}
48
49const DeleteSession = `-- name: DeleteSession :exec
50DELETE FROM sessions WHERE id = ?
51`
52
53func (q *Queries) DeleteSession(ctx context.Context, id string) error {
54	_, err := q.db.ExecContext(ctx, DeleteSession, id)
55	return err
56}
57
58const GetActiveBrowserSession = `-- name: GetActiveBrowserSession :one
59SELECT id, type, started_at, ended_at, process_id FROM sessions
60WHERE type = 'browser' AND ended_at IS NULL
61ORDER BY started_at DESC
62LIMIT 1
63`
64
65func (q *Queries) GetActiveBrowserSession(ctx context.Context) (Session, error) {
66	row := q.db.QueryRowContext(ctx, GetActiveBrowserSession)
67	var i Session
68	err := row.Scan(
69		&i.ID,
70		&i.Type,
71		&i.StartedAt,
72		&i.EndedAt,
73		&i.ProcessID,
74	)
75	return i, err
76}
77
78const GetRecentSessions = `-- name: GetRecentSessions :many
79SELECT id, type, started_at, ended_at, process_id FROM sessions
80ORDER BY started_at DESC
81LIMIT ?
82`
83
84func (q *Queries) GetRecentSessions(ctx context.Context, limit int64) ([]Session, error) {
85	rows, err := q.db.QueryContext(ctx, GetRecentSessions, limit)
86	if err != nil {
87		return nil, err
88	}
89	defer rows.Close()
90	items := []Session{}
91	for rows.Next() {
92		var i Session
93		if err := rows.Scan(
94			&i.ID,
95			&i.Type,
96			&i.StartedAt,
97			&i.EndedAt,
98			&i.ProcessID,
99		); err != nil {
100			return nil, err
101		}
102		items = append(items, i)
103	}
104	if err := rows.Close(); err != nil {
105		return nil, err
106	}
107	if err := rows.Err(); err != nil {
108		return nil, err
109	}
110	return items, nil
111}
112
113const GetSessionByID = `-- name: GetSessionByID :one
114SELECT id, type, started_at, ended_at, process_id FROM sessions WHERE id = ? LIMIT 1
115`
116
117func (q *Queries) GetSessionByID(ctx context.Context, id string) (Session, error) {
118	row := q.db.QueryRowContext(ctx, GetSessionByID, id)
119	var i Session
120	err := row.Scan(
121		&i.ID,
122		&i.Type,
123		&i.StartedAt,
124		&i.EndedAt,
125		&i.ProcessID,
126	)
127	return i, err
128}
129
130const InsertSession = `-- name: InsertSession :exec
131INSERT INTO sessions (id, type, started_at, ended_at, process_id)
132VALUES (?, ?, ?, ?, ?)
133`
134
135type InsertSessionParams struct {
136	ID        string        `json:"id"`
137	Type      string        `json:"type"`
138	StartedAt time.Time     `json:"started_at"`
139	EndedAt   sql.NullTime  `json:"ended_at"`
140	ProcessID sql.NullInt64 `json:"process_id"`
141}
142
143func (q *Queries) InsertSession(ctx context.Context, arg InsertSessionParams) error {
144	_, err := q.db.ExecContext(ctx, InsertSession,
145		arg.ID,
146		arg.Type,
147		arg.StartedAt,
148		arg.EndedAt,
149		arg.ProcessID,
150	)
151	return err
152}
153
154const MarkSessionEnded = `-- name: MarkSessionEnded :exec
155UPDATE sessions
156SET ended_at = ?
157WHERE id = ?
158`
159
160type MarkSessionEndedParams struct {
161	EndedAt sql.NullTime `json:"ended_at"`
162	ID      string       `json:"id"`
163}
164
165func (q *Queries) MarkSessionEnded(ctx context.Context, arg MarkSessionEndedParams) error {
166	_, err := q.db.ExecContext(ctx, MarkSessionEnded, arg.EndedAt, arg.ID)
167	return err
168}

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