v0.21.0 73bf644

session_states.sql.go RawHistoryFolder

1// Code generated by sqlc. DO NOT EDIT.
2// versions:
3//   sqlc v1.30.0
4// source: session_states.sql
5
6package sqlc
7
8import (
9	"context"
10	"database/sql"
11	"time"
12)
13
14const DeleteSessionState = `-- name: DeleteSessionState :exec
15DELETE FROM session_states WHERE session_id = ?
16`
17
18func (q *Queries) DeleteSessionState(ctx context.Context, sessionID string) error {
19	_, err := q.db.ExecContext(ctx, DeleteSessionState, sessionID)
20	return err
21}
22
23const GetAllSessionStates = `-- name: GetAllSessionStates :many
24SELECT session_id, state_json, version, tab_count, pane_count, updated_at
25FROM session_states
26ORDER BY updated_at DESC
27`
28
29func (q *Queries) GetAllSessionStates(ctx context.Context) ([]SessionState, error) {
30	rows, err := q.db.QueryContext(ctx, GetAllSessionStates)
31	if err != nil {
32		return nil, err
33	}
34	defer rows.Close()
35	items := []SessionState{}
36	for rows.Next() {
37		var i SessionState
38		if err := rows.Scan(
39			&i.SessionID,
40			&i.StateJson,
41			&i.Version,
42			&i.TabCount,
43			&i.PaneCount,
44			&i.UpdatedAt,
45		); err != nil {
46			return nil, err
47		}
48		items = append(items, i)
49	}
50	if err := rows.Close(); err != nil {
51		return nil, err
52	}
53	if err := rows.Err(); err != nil {
54		return nil, err
55	}
56	return items, nil
57}
58
59const GetSessionState = `-- name: GetSessionState :one
60SELECT session_id, state_json, version, tab_count, pane_count, updated_at
61FROM session_states
62WHERE session_id = ?
63`
64
65func (q *Queries) GetSessionState(ctx context.Context, sessionID string) (SessionState, error) {
66	row := q.db.QueryRowContext(ctx, GetSessionState, sessionID)
67	var i SessionState
68	err := row.Scan(
69		&i.SessionID,
70		&i.StateJson,
71		&i.Version,
72		&i.TabCount,
73		&i.PaneCount,
74		&i.UpdatedAt,
75	)
76	return i, err
77}
78
79const GetSessionsWithState = `-- name: GetSessionsWithState :many
80SELECT 
81    s.id, s.type, s.started_at, s.ended_at,
82    ss.state_json, ss.tab_count, ss.pane_count, ss.updated_at as state_updated_at
83FROM sessions s
84LEFT JOIN session_states ss ON s.id = ss.session_id
85WHERE s.type = 'browser'
86ORDER BY s.started_at DESC
87LIMIT ?
88`
89
90type GetSessionsWithStateRow struct {
91	ID             string         `json:"id"`
92	Type           string         `json:"type"`
93	StartedAt      time.Time      `json:"started_at"`
94	EndedAt        sql.NullTime   `json:"ended_at"`
95	StateJson      sql.NullString `json:"state_json"`
96	TabCount       sql.NullInt64  `json:"tab_count"`
97	PaneCount      sql.NullInt64  `json:"pane_count"`
98	StateUpdatedAt sql.NullTime   `json:"state_updated_at"`
99}
100
101func (q *Queries) GetSessionsWithState(ctx context.Context, limit int64) ([]GetSessionsWithStateRow, error) {
102	rows, err := q.db.QueryContext(ctx, GetSessionsWithState, limit)
103	if err != nil {
104		return nil, err
105	}
106	defer rows.Close()
107	items := []GetSessionsWithStateRow{}
108	for rows.Next() {
109		var i GetSessionsWithStateRow
110		if err := rows.Scan(
111			&i.ID,
112			&i.Type,
113			&i.StartedAt,
114			&i.EndedAt,
115			&i.StateJson,
116			&i.TabCount,
117			&i.PaneCount,
118			&i.StateUpdatedAt,
119		); err != nil {
120			return nil, err
121		}
122		items = append(items, i)
123	}
124	if err := rows.Close(); err != nil {
125		return nil, err
126	}
127	if err := rows.Err(); err != nil {
128		return nil, err
129	}
130	return items, nil
131}
132
133const GetTotalSessionStatesSize = `-- name: GetTotalSessionStatesSize :one
134SELECT COALESCE(SUM(LENGTH(state_json)), 0) as total_size
135FROM session_states
136`
137
138func (q *Queries) GetTotalSessionStatesSize(ctx context.Context) (interface{}, error) {
139	row := q.db.QueryRowContext(ctx, GetTotalSessionStatesSize)
140	var total_size interface{}
141	err := row.Scan(&total_size)
142	return total_size, err
143}
144
145const UpsertSessionState = `-- name: UpsertSessionState :exec
146INSERT INTO session_states (session_id, state_json, version, tab_count, pane_count, updated_at)
147VALUES (?, ?, ?, ?, ?, ?)
148ON CONFLICT(session_id) DO UPDATE SET
149    state_json = excluded.state_json,
150    version = excluded.version,
151    tab_count = excluded.tab_count,
152    pane_count = excluded.pane_count,
153    updated_at = excluded.updated_at
154`
155
156type UpsertSessionStateParams struct {
157	SessionID string    `json:"session_id"`
158	StateJson string    `json:"state_json"`
159	Version   int64     `json:"version"`
160	TabCount  int64     `json:"tab_count"`
161	PaneCount int64     `json:"pane_count"`
162	UpdatedAt time.Time `json:"updated_at"`
163}
164
165func (q *Queries) UpsertSessionState(ctx context.Context, arg UpsertSessionStateParams) error {
166	_, err := q.db.ExecContext(ctx, UpsertSessionState,
167		arg.SessionID,
168		arg.StateJson,
169		arg.Version,
170		arg.TabCount,
171		arg.PaneCount,
172		arg.UpdatedAt,
173	)
174	return err
175}

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