Go · 1484 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4 // source: runner_jwt_used.sql
5
6 package actionsdb
7
8 import (
9 "context"
10
11 "github.com/jackc/pgx/v5/pgtype"
12 )
13
14 const deleteOldRunnerJWTUsesForCleanup = `-- name: DeleteOldRunnerJWTUsesForCleanup :execrows
15 DELETE FROM runner_jwt_used WHERE expires_at < $1
16 `
17
18 func (q *Queries) DeleteOldRunnerJWTUsesForCleanup(ctx context.Context, db DBTX, expiresAt pgtype.Timestamptz) (int64, error) {
19 result, err := db.Exec(ctx, deleteOldRunnerJWTUsesForCleanup, expiresAt)
20 if err != nil {
21 return 0, err
22 }
23 return result.RowsAffected(), nil
24 }
25
26 const markRunnerJWTUsed = `-- name: MarkRunnerJWTUsed :one
27
28 INSERT INTO runner_jwt_used (jti, runner_id, job_id, run_id, repo_id, expires_at)
29 VALUES ($1, $2, $3, $4, $5, $6)
30 ON CONFLICT (jti) DO NOTHING
31 RETURNING jti, runner_id, job_id, run_id, repo_id, expires_at, used_at
32 `
33
34 type MarkRunnerJWTUsedParams struct {
35 Jti string
36 RunnerID int64
37 JobID int64
38 RunID int64
39 RepoID int64
40 ExpiresAt pgtype.Timestamptz
41 }
42
43 // SPDX-License-Identifier: AGPL-3.0-or-later
44 func (q *Queries) MarkRunnerJWTUsed(ctx context.Context, db DBTX, arg MarkRunnerJWTUsedParams) (RunnerJwtUsed, error) {
45 row := db.QueryRow(ctx, markRunnerJWTUsed,
46 arg.Jti,
47 arg.RunnerID,
48 arg.JobID,
49 arg.RunID,
50 arg.RepoID,
51 arg.ExpiresAt,
52 )
53 var i RunnerJwtUsed
54 err := row.Scan(
55 &i.Jti,
56 &i.RunnerID,
57 &i.JobID,
58 &i.RunID,
59 &i.RepoID,
60 &i.ExpiresAt,
61 &i.UsedAt,
62 )
63 return i, err
64 }
65