Files
query-orchestration/internal/database/repository/job.sql.go
T
Michael McGuinness 750abe1be3 Merged in feature/entitylogs (pull request #67)
Query Version Update
2025-02-14 18:43:26 +00:00

120 lines
3.0 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// source: job.sql
package repository
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const addJobCanSync = `-- name: AddJobCanSync :exec
INSERT INTO jobCanSync (canSync, jobId) VALUES ($1, $2)
`
type AddJobCanSyncParams struct {
Cansync bool `db:"cansync"`
Jobid pgtype.UUID `db:"jobid"`
}
// AddJobCanSync
//
// INSERT INTO jobCanSync (canSync, jobId) VALUES ($1, $2)
func (q *Queries) AddJobCanSync(ctx context.Context, arg *AddJobCanSyncParams) error {
_, err := q.db.Exec(ctx, addJobCanSync, arg.Cansync, arg.Jobid)
return err
}
const createJob = `-- name: CreateJob :one
INSERT INTO jobs (clientId) VALUES ($1) RETURNING id
`
// CreateJob
//
// INSERT INTO jobs (clientId) VALUES ($1) RETURNING id
func (q *Queries) CreateJob(ctx context.Context, clientid pgtype.UUID) (pgtype.UUID, error) {
row := q.db.QueryRow(ctx, createJob, clientid)
var id pgtype.UUID
err := row.Scan(&id)
return id, err
}
const getJob = `-- name: GetJob :one
SELECT j.id, j.clientId, coalesce(cs.canSync, false) as canSync
FROM jobs as j
LEFT JOIN (
SELECT jobId, canSync
FROM jobCanSync
WHERE jobId = $1
ORDER BY id DESC
LIMIT 1
) as cs on cs.jobId = j.id
WHERE j.id = $1
`
type GetJobRow struct {
ID pgtype.UUID `db:"id"`
Clientid pgtype.UUID `db:"clientid"`
Cansync bool `db:"cansync"`
}
// GetJob
//
// SELECT j.id, j.clientId, coalesce(cs.canSync, false) as canSync
// FROM jobs as j
// LEFT JOIN (
// SELECT jobId, canSync
// FROM jobCanSync
// WHERE jobId = $1
// ORDER BY id DESC
// LIMIT 1
// ) as cs on cs.jobId = j.id
// WHERE j.id = $1
func (q *Queries) GetJob(ctx context.Context, jobid pgtype.UUID) (*GetJobRow, error) {
row := q.db.QueryRow(ctx, getJob, jobid)
var i GetJobRow
err := row.Scan(&i.ID, &i.Clientid, &i.Cansync)
return &i, err
}
const listJobDocumentIDsBatch = `-- name: ListJobDocumentIDsBatch :many
SELECT id, totalCount FROM listJobDocumentIDs($1, $2, $3)
`
type ListJobDocumentIDsBatchParams struct {
Jobid pgtype.UUID `db:"jobid"`
Batchsize int32 `db:"batchsize"`
Pageoffset int32 `db:"pageoffset"`
}
type ListJobDocumentIDsBatchRow struct {
ID pgtype.UUID `db:"id"`
Totalcount *int64 `db:"totalcount"`
}
// ListJobDocumentIDsBatch
//
// SELECT id, totalCount FROM listJobDocumentIDs($1, $2, $3)
func (q *Queries) ListJobDocumentIDsBatch(ctx context.Context, arg *ListJobDocumentIDsBatchParams) ([]*ListJobDocumentIDsBatchRow, error) {
rows, err := q.db.Query(ctx, listJobDocumentIDsBatch, arg.Jobid, arg.Batchsize, arg.Pageoffset)
if err != nil {
return nil, err
}
defer rows.Close()
items := []*ListJobDocumentIDsBatchRow{}
for rows.Next() {
var i ListJobDocumentIDsBatchRow
if err := rows.Scan(&i.ID, &i.Totalcount); err != nil {
return nil, err
}
items = append(items, &i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}