| 1 | // Code generated by sqlc. DO NOT EDIT. |
| 2 | // versions: |
| 3 | // sqlc v1.31.1 |
| 4 | // source: workflow_jobs.sql |
| 5 | |
| 6 | package actionsdb |
| 7 | |
| 8 | import ( |
| 9 | "context" |
| 10 | |
| 11 | "github.com/jackc/pgx/v5/pgtype" |
| 12 | ) |
| 13 | |
| 14 | const getWorkflowJobByID = `-- name: GetWorkflowJobByID :one |
| 15 | SELECT id, run_id, job_index, job_key, job_name, runs_on, |
| 16 | runner_id, needs_jobs, if_expr, timeout_minutes, permissions, |
| 17 | job_env, status, conclusion, cancel_requested, |
| 18 | started_at, completed_at, version, created_at, updated_at |
| 19 | FROM workflow_jobs |
| 20 | WHERE id = $1 |
| 21 | ` |
| 22 | |
| 23 | func (q *Queries) GetWorkflowJobByID(ctx context.Context, db DBTX, id int64) (WorkflowJob, error) { |
| 24 | row := db.QueryRow(ctx, getWorkflowJobByID, id) |
| 25 | var i WorkflowJob |
| 26 | err := row.Scan( |
| 27 | &i.ID, |
| 28 | &i.RunID, |
| 29 | &i.JobIndex, |
| 30 | &i.JobKey, |
| 31 | &i.JobName, |
| 32 | &i.RunsOn, |
| 33 | &i.RunnerID, |
| 34 | &i.NeedsJobs, |
| 35 | &i.IfExpr, |
| 36 | &i.TimeoutMinutes, |
| 37 | &i.Permissions, |
| 38 | &i.JobEnv, |
| 39 | &i.Status, |
| 40 | &i.Conclusion, |
| 41 | &i.CancelRequested, |
| 42 | &i.StartedAt, |
| 43 | &i.CompletedAt, |
| 44 | &i.Version, |
| 45 | &i.CreatedAt, |
| 46 | &i.UpdatedAt, |
| 47 | ) |
| 48 | return i, err |
| 49 | } |
| 50 | |
| 51 | const insertWorkflowJob = `-- name: InsertWorkflowJob :one |
| 52 | |
| 53 | INSERT INTO workflow_jobs ( |
| 54 | run_id, job_index, job_key, job_name, |
| 55 | runs_on, needs_jobs, if_expr, timeout_minutes, |
| 56 | permissions, job_env |
| 57 | ) VALUES ( |
| 58 | $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 |
| 59 | ) |
| 60 | RETURNING id, run_id, job_index, job_key, job_name, runs_on, |
| 61 | runner_id, needs_jobs, if_expr, timeout_minutes, permissions, |
| 62 | job_env, status, conclusion, cancel_requested, |
| 63 | started_at, completed_at, version, created_at, updated_at |
| 64 | ` |
| 65 | |
| 66 | type InsertWorkflowJobParams struct { |
| 67 | RunID int64 |
| 68 | JobIndex int32 |
| 69 | JobKey string |
| 70 | JobName string |
| 71 | RunsOn string |
| 72 | NeedsJobs []string |
| 73 | IfExpr string |
| 74 | TimeoutMinutes int32 |
| 75 | Permissions []byte |
| 76 | JobEnv []byte |
| 77 | } |
| 78 | |
| 79 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 80 | func (q *Queries) InsertWorkflowJob(ctx context.Context, db DBTX, arg InsertWorkflowJobParams) (WorkflowJob, error) { |
| 81 | row := db.QueryRow(ctx, insertWorkflowJob, |
| 82 | arg.RunID, |
| 83 | arg.JobIndex, |
| 84 | arg.JobKey, |
| 85 | arg.JobName, |
| 86 | arg.RunsOn, |
| 87 | arg.NeedsJobs, |
| 88 | arg.IfExpr, |
| 89 | arg.TimeoutMinutes, |
| 90 | arg.Permissions, |
| 91 | arg.JobEnv, |
| 92 | ) |
| 93 | var i WorkflowJob |
| 94 | err := row.Scan( |
| 95 | &i.ID, |
| 96 | &i.RunID, |
| 97 | &i.JobIndex, |
| 98 | &i.JobKey, |
| 99 | &i.JobName, |
| 100 | &i.RunsOn, |
| 101 | &i.RunnerID, |
| 102 | &i.NeedsJobs, |
| 103 | &i.IfExpr, |
| 104 | &i.TimeoutMinutes, |
| 105 | &i.Permissions, |
| 106 | &i.JobEnv, |
| 107 | &i.Status, |
| 108 | &i.Conclusion, |
| 109 | &i.CancelRequested, |
| 110 | &i.StartedAt, |
| 111 | &i.CompletedAt, |
| 112 | &i.Version, |
| 113 | &i.CreatedAt, |
| 114 | &i.UpdatedAt, |
| 115 | ) |
| 116 | return i, err |
| 117 | } |
| 118 | |
| 119 | const listJobsForRun = `-- name: ListJobsForRun :many |
| 120 | SELECT id, run_id, job_index, job_key, job_name, runs_on, status, |
| 121 | conclusion, started_at, completed_at, created_at |
| 122 | FROM workflow_jobs |
| 123 | WHERE run_id = $1 |
| 124 | ORDER BY job_index ASC |
| 125 | ` |
| 126 | |
| 127 | type ListJobsForRunRow struct { |
| 128 | ID int64 |
| 129 | RunID int64 |
| 130 | JobIndex int32 |
| 131 | JobKey string |
| 132 | JobName string |
| 133 | RunsOn string |
| 134 | Status WorkflowJobStatus |
| 135 | Conclusion NullCheckConclusion |
| 136 | StartedAt pgtype.Timestamptz |
| 137 | CompletedAt pgtype.Timestamptz |
| 138 | CreatedAt pgtype.Timestamptz |
| 139 | } |
| 140 | |
| 141 | func (q *Queries) ListJobsForRun(ctx context.Context, db DBTX, runID int64) ([]ListJobsForRunRow, error) { |
| 142 | rows, err := db.Query(ctx, listJobsForRun, runID) |
| 143 | if err != nil { |
| 144 | return nil, err |
| 145 | } |
| 146 | defer rows.Close() |
| 147 | items := []ListJobsForRunRow{} |
| 148 | for rows.Next() { |
| 149 | var i ListJobsForRunRow |
| 150 | if err := rows.Scan( |
| 151 | &i.ID, |
| 152 | &i.RunID, |
| 153 | &i.JobIndex, |
| 154 | &i.JobKey, |
| 155 | &i.JobName, |
| 156 | &i.RunsOn, |
| 157 | &i.Status, |
| 158 | &i.Conclusion, |
| 159 | &i.StartedAt, |
| 160 | &i.CompletedAt, |
| 161 | &i.CreatedAt, |
| 162 | ); err != nil { |
| 163 | return nil, err |
| 164 | } |
| 165 | items = append(items, i) |
| 166 | } |
| 167 | if err := rows.Err(); err != nil { |
| 168 | return nil, err |
| 169 | } |
| 170 | return items, nil |
| 171 | } |
| 172 |