Go · 3708 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 listStepLogChunks = `-- name: ListStepLogChunks :many
108 SELECT id, step_id, seq, chunk, created_at
109 FROM workflow_step_log_chunks
110 WHERE step_id = $1 AND seq > $2
111 ORDER BY seq ASC
112 LIMIT $3
113 `
114
115 type ListStepLogChunksParams struct {
116 StepID int64
117 Seq int32
118 Limit int32
119 }
120
121 func (q *Queries) ListStepLogChunks(ctx context.Context, db DBTX, arg ListStepLogChunksParams) ([]WorkflowStepLogChunk, error) {
122 rows, err := db.Query(ctx, listStepLogChunks, arg.StepID, arg.Seq, arg.Limit)
123 if err != nil {
124 return nil, err
125 }
126 defer rows.Close()
127 items := []WorkflowStepLogChunk{}
128 for rows.Next() {
129 var i WorkflowStepLogChunk
130 if err := rows.Scan(
131 &i.ID,
132 &i.StepID,
133 &i.Seq,
134 &i.Chunk,
135 &i.CreatedAt,
136 ); err != nil {
137 return nil, err
138 }
139 items = append(items, i)
140 }
141 if err := rows.Err(); err != nil {
142 return nil, err
143 }
144 return items, nil
145 }
146
147 const updateStepLogChunk = `-- name: UpdateStepLogChunk :exec
148 UPDATE workflow_step_log_chunks
149 SET chunk = $2
150 WHERE id = $1
151 `
152
153 type UpdateStepLogChunkParams struct {
154 ID int64
155 Chunk []byte
156 }
157
158 func (q *Queries) UpdateStepLogChunk(ctx context.Context, db DBTX, arg UpdateStepLogChunkParams) error {
159 _, err := db.Exec(ctx, updateStepLogChunk, arg.ID, arg.Chunk)
160 return err
161 }
162