// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: ai_runs.sql package db import ( "context" "database/sql" ) const clearSuggestionBatchAIRunsBefore = `-- name: ClearSuggestionBatchAIRunsBefore :execrows UPDATE suggestion_batches SET ai_run_id = NULL WHERE ai_run_id IN (SELECT ai_runs.id FROM ai_runs WHERE ai_runs.created_at < ?1) ` // Drops references to the runs created before the cutoff, so the purge // can delete them. func (q *Queries) ClearSuggestionBatchAIRunsBefore(ctx context.Context, cutoff string) (int64, error) { result, err := q.db.ExecContext(ctx, clearSuggestionBatchAIRunsBefore, cutoff) if err != nil { return 0, err } return result.RowsAffected() } const clearWeekPlanAIRunsBefore = `-- name: ClearWeekPlanAIRunsBefore :execrows UPDATE week_plans SET ai_run_id = NULL WHERE ai_run_id IN (SELECT ai_runs.id FROM ai_runs WHERE ai_runs.created_at < ?1) ` // Drops references to the runs created before the cutoff, so the purge // can delete them. func (q *Queries) ClearWeekPlanAIRunsBefore(ctx context.Context, cutoff string) (int64, error) { result, err := q.db.ExecContext(ctx, clearWeekPlanAIRunsBefore, cutoff) if err != nil { return 0, err } return result.RowsAffected() } const createAIRun = `-- name: CreateAIRun :exec INSERT INTO ai_runs ( id, skill, skill_version, provider, model, temperature, status, latency_ms, tokens_in, tokens_out, error, request_redacted, response_redacted, created_at, updated_at ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ` type CreateAIRunParams struct { ID string Skill string SkillVersion string Provider string Model string Temperature float64 Status string LatencyMs sql.NullInt64 TokensIn sql.NullInt64 TokensOut sql.NullInt64 Error sql.NullString RequestRedacted string ResponseRedacted sql.NullString CreatedAt string UpdatedAt string } func (q *Queries) CreateAIRun(ctx context.Context, arg CreateAIRunParams) error { _, err := q.db.ExecContext(ctx, createAIRun, arg.ID, arg.Skill, arg.SkillVersion, arg.Provider, arg.Model, arg.Temperature, arg.Status, arg.LatencyMs, arg.TokensIn, arg.TokensOut, arg.Error, arg.RequestRedacted, arg.ResponseRedacted, arg.CreatedAt, arg.UpdatedAt, ) return err } const deleteAIRunsBefore = `-- name: DeleteAIRunsBefore :execrows DELETE FROM ai_runs WHERE created_at < ?1 ` func (q *Queries) DeleteAIRunsBefore(ctx context.Context, cutoff string) (int64, error) { result, err := q.db.ExecContext(ctx, deleteAIRunsBefore, cutoff) if err != nil { return 0, err } return result.RowsAffected() }