Go · 4468 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4 // source: workflow_step_log_chunks.sql
5
6 package actionsdb
7
8 import (
9 "context"
10
11 "github.com/jackc/pgx/v5/pgtype"
12 )
13
14 const appendStepLogChunk = `-- name: AppendStepLogChunk :one
15
16 INSERT INTO workflow_step_log_chunks (step_id, seq, chunk)
17 VALUES ($1, $2, $3)
18 ON CONFLICT (step_id, seq) DO NOTHING
19 RETURNING id, step_id, seq, created_at
20 `
21
22 type AppendStepLogChunkParams struct {
23 StepID int64
24 Seq int32
25 Chunk []byte
26 }
27
28 type AppendStepLogChunkRow struct {
29 ID int64
30 StepID int64
31 Seq int32
32 CreatedAt pgtype.Timestamptz
33 }
34
35 // SPDX-License-Identifier: AGPL-3.0-or-later
36 func (q *Queries) AppendStepLogChunk(ctx context.Context, db DBTX, arg AppendStepLogChunkParams) (AppendStepLogChunkRow, error) {
37 row := db.QueryRow(ctx, appendStepLogChunk, arg.StepID, arg.Seq, arg.Chunk)
38 var i AppendStepLogChunkRow
39 err := row.Scan(
40 &i.ID,
41 &i.StepID,
42 &i.Seq,
43 &i.CreatedAt,
44 )
45 return i, err
46 }
47
48 const deleteStepLogChunks = `-- name: DeleteStepLogChunks :exec
49 DELETE FROM workflow_step_log_chunks WHERE step_id = $1
50 `
51
52 func (q *Queries) DeleteStepLogChunks(ctx context.Context, db DBTX, stepID int64) error {
53 _, err := db.Exec(ctx, deleteStepLogChunks, stepID)
54 return err
55 }
56
57 const getStepLogChunkBefore = `-- name: GetStepLogChunkBefore :one
58 SELECT id, step_id, seq, chunk, created_at
59 FROM workflow_step_log_chunks
60 WHERE step_id = $1 AND seq < $2
61 ORDER BY seq DESC
62 LIMIT 1
63 `
64
65 type GetStepLogChunkBeforeParams struct {
66 StepID int64
67 Seq int32
68 }
69
70 func (q *Queries) GetStepLogChunkBefore(ctx context.Context, db DBTX, arg GetStepLogChunkBeforeParams) (WorkflowStepLogChunk, error) {
71 row := db.QueryRow(ctx, getStepLogChunkBefore, arg.StepID, arg.Seq)
72 var i WorkflowStepLogChunk
73 err := row.Scan(
74 &i.ID,
75 &i.StepID,
76 &i.Seq,
77 &i.Chunk,
78 &i.CreatedAt,
79 )
80 return i, err
81 }
82
83 const getStepLogChunkByStepSeq = `-- name: GetStepLogChunkByStepSeq :one
84 SELECT id, step_id, seq, chunk, created_at
85 FROM workflow_step_log_chunks
86 WHERE step_id = $1 AND seq = $2
87 `
88
89 type GetStepLogChunkByStepSeqParams struct {
90 StepID int64
91 Seq int32
92 }
93
94 func (q *Queries) GetStepLogChunkByStepSeq(ctx context.Context, db DBTX, arg GetStepLogChunkByStepSeqParams) (WorkflowStepLogChunk, error) {
95 row := db.QueryRow(ctx, getStepLogChunkByStepSeq, arg.StepID, arg.Seq)
96 var i WorkflowStepLogChunk
97 err := row.Scan(
98 &i.ID,
99 &i.StepID,
100 &i.Seq,
101 &i.Chunk,
102 &i.CreatedAt,
103 )
104 return i, err
105 }
106
107 const listAllStepLogChunksForStep = `-- name: ListAllStepLogChunksForStep :many
108 SELECT id, step_id, seq, chunk, created_at
109 FROM workflow_step_log_chunks
110 WHERE step_id = $1
111 ORDER BY seq ASC
112 `
113
114 func (q *Queries) ListAllStepLogChunksForStep(ctx context.Context, db DBTX, stepID int64) ([]WorkflowStepLogChunk, error) {
115 rows, err := db.Query(ctx, listAllStepLogChunksForStep, stepID)
116 if err != nil {
117 return nil, err
118 }
119 defer rows.Close()
120 items := []WorkflowStepLogChunk{}
121 for rows.Next() {
122 var i WorkflowStepLogChunk
123 if err := rows.Scan(
124 &i.ID,
125 &i.StepID,
126 &i.Seq,
127 &i.Chunk,
128 &i.CreatedAt,
129 ); err != nil {
130 return nil, err
131 }
132 items = append(items, i)
133 }
134 if err := rows.Err(); err != nil {
135 return nil, err
136 }
137 return items, nil
138 }
139
140 const listStepLogChunks = `-- name: ListStepLogChunks :many
141 SELECT id, step_id, seq, chunk, created_at
142 FROM workflow_step_log_chunks
143 WHERE step_id = $1 AND seq > $2
144 ORDER BY seq ASC
145 LIMIT $3
146 `
147
148 type ListStepLogChunksParams struct {
149 StepID int64
150 Seq int32
151 Limit int32
152 }
153
154 func (q *Queries) ListStepLogChunks(ctx context.Context, db DBTX, arg ListStepLogChunksParams) ([]WorkflowStepLogChunk, error) {
155 rows, err := db.Query(ctx, listStepLogChunks, arg.StepID, arg.Seq, arg.Limit)
156 if err != nil {
157 return nil, err
158 }
159 defer rows.Close()
160 items := []WorkflowStepLogChunk{}
161 for rows.Next() {
162 var i WorkflowStepLogChunk
163 if err := rows.Scan(
164 &i.ID,
165 &i.StepID,
166 &i.Seq,
167 &i.Chunk,
168 &i.CreatedAt,
169 ); err != nil {
170 return nil, err
171 }
172 items = append(items, i)
173 }
174 if err := rows.Err(); err != nil {
175 return nil, err
176 }
177 return items, nil
178 }
179
180 const updateStepLogChunk = `-- name: UpdateStepLogChunk :exec
181 UPDATE workflow_step_log_chunks
182 SET chunk = $2
183 WHERE id = $1
184 `
185
186 type UpdateStepLogChunkParams struct {
187 ID int64
188 Chunk []byte
189 }
190
191 func (q *Queries) UpdateStepLogChunk(ctx context.Context, db DBTX, arg UpdateStepLogChunkParams) error {
192 _, err := db.Exec(ctx, updateStepLogChunk, arg.ID, arg.Chunk)
193 return err
194 }
195