160 lines
3.9 KiB
Go
160 lines
3.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: assessment_leak_traces.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const findAssessmentTraceStatements = `-- name: FindAssessmentTraceStatements :many
|
|
SELECT
|
|
item.attempt_id,
|
|
(item.variant ->> 'Statement')::text AS statement
|
|
FROM assessment_attempt_items AS item
|
|
INNER JOIN assessment_attempts AS attempt ON item.attempt_id = attempt.id
|
|
WHERE
|
|
attempt.kind IN ('root', 'corrective')
|
|
AND position($1::text IN regexp_replace((item.variant ->> 'Statement')::text, '\s+', ' ', 'g')) > 0
|
|
ORDER BY item.attempt_id, item.ordinal
|
|
LIMIT $2
|
|
`
|
|
|
|
type FindAssessmentTraceStatementsParams struct {
|
|
Fragment string
|
|
RowLimit int32
|
|
}
|
|
|
|
type FindAssessmentTraceStatementsRow struct {
|
|
AttemptID pgtype.UUID
|
|
Statement string
|
|
}
|
|
|
|
// The unmarked statements of real attempts whose text, with runs of white space
|
|
// collapsed, contains the fragment. The fragment is matched literally: position
|
|
// is not a pattern. The scan reads the stored variant of every item, which is
|
|
// fine for an operator command and not for a request path.
|
|
func (q *Queries) FindAssessmentTraceStatements(ctx context.Context, arg FindAssessmentTraceStatementsParams) ([]FindAssessmentTraceStatementsRow, error) {
|
|
rows, err := q.db.Query(ctx, findAssessmentTraceStatements, arg.Fragment, arg.RowLimit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []FindAssessmentTraceStatementsRow
|
|
for rows.Next() {
|
|
var i FindAssessmentTraceStatementsRow
|
|
if err := rows.Scan(&i.AttemptID, &i.Statement); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const insertAssessmentLeakTrace = `-- name: InsertAssessmentLeakTrace :exec
|
|
INSERT INTO assessment_leak_traces (
|
|
id,
|
|
actor,
|
|
searched_at,
|
|
text_digest,
|
|
key_version,
|
|
text_runes,
|
|
status,
|
|
method,
|
|
attempt_id,
|
|
candidates,
|
|
evidence_bits
|
|
) VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7,
|
|
$8,
|
|
$9,
|
|
$10,
|
|
$11
|
|
)
|
|
`
|
|
|
|
type InsertAssessmentLeakTraceParams struct {
|
|
ID pgtype.UUID
|
|
Actor string
|
|
SearchedAt pgtype.Timestamptz
|
|
TextDigest []byte
|
|
KeyVersion int16
|
|
TextRunes int32
|
|
Status string
|
|
Method pgtype.Text
|
|
AttemptID pgtype.UUID
|
|
Candidates int32
|
|
EvidenceBits int32
|
|
}
|
|
|
|
func (q *Queries) InsertAssessmentLeakTrace(ctx context.Context, arg InsertAssessmentLeakTraceParams) error {
|
|
_, err := q.db.Exec(ctx, insertAssessmentLeakTrace,
|
|
arg.ID,
|
|
arg.Actor,
|
|
arg.SearchedAt,
|
|
arg.TextDigest,
|
|
arg.KeyVersion,
|
|
arg.TextRunes,
|
|
arg.Status,
|
|
arg.Method,
|
|
arg.AttemptID,
|
|
arg.Candidates,
|
|
arg.EvidenceBits,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const listAssessmentTraceAttempts = `-- name: ListAssessmentTraceAttempts :many
|
|
SELECT id, created_at, expires_at
|
|
FROM assessment_attempts
|
|
WHERE kind IN ('root', 'corrective') AND id > $1
|
|
ORDER BY id
|
|
LIMIT $2
|
|
`
|
|
|
|
type ListAssessmentTraceAttemptsParams struct {
|
|
AfterID pgtype.UUID
|
|
RowLimit int32
|
|
}
|
|
|
|
type ListAssessmentTraceAttemptsRow struct {
|
|
ID pgtype.UUID
|
|
CreatedAt pgtype.Timestamptz
|
|
ExpiresAt pgtype.Timestamptz
|
|
}
|
|
|
|
// Real attempts in ascending identifier order, so that a caller can walk all of
|
|
// them in pages. Only the identifier and the time span are read.
|
|
func (q *Queries) ListAssessmentTraceAttempts(ctx context.Context, arg ListAssessmentTraceAttemptsParams) ([]ListAssessmentTraceAttemptsRow, error) {
|
|
rows, err := q.db.Query(ctx, listAssessmentTraceAttempts, arg.AfterID, arg.RowLimit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListAssessmentTraceAttemptsRow
|
|
for rows.Next() {
|
|
var i ListAssessmentTraceAttemptsRow
|
|
if err := rows.Scan(&i.ID, &i.CreatedAt, &i.ExpiresAt); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|