// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: queries-processing_jobs.sql package sqlc import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const createProcessingJob = `-- name: CreateProcessingJob :one INSERT INTO processing_jobs ( file_id, job_type ) VALUES ($1,$2 ) RETURNING id, file_id, created, started, completed, status, job_type, error, messages ` type CreateProcessingJobParams struct { FileID pgtype.UUID JobType pgtype.Text } func (q *Queries) CreateProcessingJob(ctx context.Context, arg CreateProcessingJobParams) (ProcessingJob, error) { row := q.db.QueryRow(ctx, createProcessingJob, arg.FileID, arg.JobType) var i ProcessingJob err := row.Scan( &i.ID, &i.FileID, &i.Created, &i.Started, &i.Completed, &i.Status, &i.JobType, &i.Error, &i.Messages, ) return i, err } const finishProcessingJob = `-- name: FinishProcessingJob :exec UPDATE processing_jobs SET completed = NOW(), status = "completed" WHERE id = $1 ` func (q *Queries) FinishProcessingJob(ctx context.Context, id int32) error { _, err := q.db.Exec(ctx, finishProcessingJob, id) return err } const getJob = `-- name: GetJob :one SELECT id, file_id, created, started, completed, status, job_type, error, messages FROM processing_jobs WHERE id = $1 LIMIT 1 ` func (q *Queries) GetJob(ctx context.Context, id int32) (ProcessingJob, error) { row := q.db.QueryRow(ctx, getJob, id) var i ProcessingJob err := row.Scan( &i.ID, &i.FileID, &i.Created, &i.Started, &i.Completed, &i.Status, &i.JobType, &i.Error, &i.Messages, ) return i, err } const getJobsForFile = `-- name: GetJobsForFile :many SELECT id, file_id, created, started, completed, status, job_type, error, messages FROM processing_jobs WHERE file_id = $1 ` func (q *Queries) GetJobsForFile(ctx context.Context, fileID pgtype.UUID) ([]ProcessingJob, error) { rows, err := q.db.Query(ctx, getJobsForFile, fileID) if err != nil { return nil, err } defer rows.Close() var items []ProcessingJob for rows.Next() { var i ProcessingJob if err := rows.Scan( &i.ID, &i.FileID, &i.Created, &i.Started, &i.Completed, &i.Status, &i.JobType, &i.Error, &i.Messages, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const startProcessingJob = `-- name: StartProcessingJob :exec UPDATE processing_jobs SET started = NOW(), status = "started" WHERE id = $1 ` func (q *Queries) StartProcessingJob(ctx context.Context, id int32) error { _, err := q.db.Exec(ctx, startProcessingJob, id) return err }