| 1 | // Code generated by sqlc. DO NOT EDIT. |
| 2 | // versions: |
| 3 | // sqlc v1.31.1 |
| 4 | // source: checks.sql |
| 5 | |
| 6 | package checksdb |
| 7 | |
| 8 | import ( |
| 9 | "context" |
| 10 | |
| 11 | "github.com/jackc/pgx/v5/pgtype" |
| 12 | ) |
| 13 | |
| 14 | const createCheckRun = `-- name: CreateCheckRun :one |
| 15 | INSERT INTO check_runs ( |
| 16 | suite_id, repo_id, head_sha, name, |
| 17 | status, conclusion, |
| 18 | started_at, completed_at, |
| 19 | details_url, output, external_id |
| 20 | ) VALUES ( |
| 21 | $1, $2, $3, $4, |
| 22 | $5, $8::check_conclusion, |
| 23 | $9::timestamptz, $10::timestamptz, |
| 24 | $6, $7, $11::text |
| 25 | ) |
| 26 | RETURNING id, suite_id, repo_id, head_sha, name, status, conclusion, started_at, completed_at, details_url, output, external_id, created_at, updated_at |
| 27 | ` |
| 28 | |
| 29 | type CreateCheckRunParams struct { |
| 30 | SuiteID int64 |
| 31 | RepoID int64 |
| 32 | HeadSha string |
| 33 | Name string |
| 34 | Status CheckStatus |
| 35 | DetailsUrl string |
| 36 | Output []byte |
| 37 | Conclusion NullCheckConclusion |
| 38 | StartedAt pgtype.Timestamptz |
| 39 | CompletedAt pgtype.Timestamptz |
| 40 | ExternalID pgtype.Text |
| 41 | } |
| 42 | |
| 43 | func (q *Queries) CreateCheckRun(ctx context.Context, db DBTX, arg CreateCheckRunParams) (CheckRun, error) { |
| 44 | row := db.QueryRow(ctx, createCheckRun, |
| 45 | arg.SuiteID, |
| 46 | arg.RepoID, |
| 47 | arg.HeadSha, |
| 48 | arg.Name, |
| 49 | arg.Status, |
| 50 | arg.DetailsUrl, |
| 51 | arg.Output, |
| 52 | arg.Conclusion, |
| 53 | arg.StartedAt, |
| 54 | arg.CompletedAt, |
| 55 | arg.ExternalID, |
| 56 | ) |
| 57 | var i CheckRun |
| 58 | err := row.Scan( |
| 59 | &i.ID, |
| 60 | &i.SuiteID, |
| 61 | &i.RepoID, |
| 62 | &i.HeadSha, |
| 63 | &i.Name, |
| 64 | &i.Status, |
| 65 | &i.Conclusion, |
| 66 | &i.StartedAt, |
| 67 | &i.CompletedAt, |
| 68 | &i.DetailsUrl, |
| 69 | &i.Output, |
| 70 | &i.ExternalID, |
| 71 | &i.CreatedAt, |
| 72 | &i.UpdatedAt, |
| 73 | ) |
| 74 | return i, err |
| 75 | } |
| 76 | |
| 77 | const getCheckRun = `-- name: GetCheckRun :one |
| 78 | SELECT id, suite_id, repo_id, head_sha, name, status, conclusion, started_at, completed_at, details_url, output, external_id, created_at, updated_at FROM check_runs WHERE id = $1 |
| 79 | ` |
| 80 | |
| 81 | func (q *Queries) GetCheckRun(ctx context.Context, db DBTX, id int64) (CheckRun, error) { |
| 82 | row := db.QueryRow(ctx, getCheckRun, id) |
| 83 | var i CheckRun |
| 84 | err := row.Scan( |
| 85 | &i.ID, |
| 86 | &i.SuiteID, |
| 87 | &i.RepoID, |
| 88 | &i.HeadSha, |
| 89 | &i.Name, |
| 90 | &i.Status, |
| 91 | &i.Conclusion, |
| 92 | &i.StartedAt, |
| 93 | &i.CompletedAt, |
| 94 | &i.DetailsUrl, |
| 95 | &i.Output, |
| 96 | &i.ExternalID, |
| 97 | &i.CreatedAt, |
| 98 | &i.UpdatedAt, |
| 99 | ) |
| 100 | return i, err |
| 101 | } |
| 102 | |
| 103 | const getCheckRunByExternalID = `-- name: GetCheckRunByExternalID :one |
| 104 | |
| 105 | SELECT id, suite_id, repo_id, head_sha, name, status, conclusion, started_at, completed_at, details_url, output, external_id, created_at, updated_at FROM check_runs |
| 106 | WHERE repo_id = $1 AND head_sha = $2 AND name = $3 AND external_id = $4 |
| 107 | ` |
| 108 | |
| 109 | type GetCheckRunByExternalIDParams struct { |
| 110 | RepoID int64 |
| 111 | HeadSha string |
| 112 | Name string |
| 113 | ExternalID pgtype.Text |
| 114 | } |
| 115 | |
| 116 | // ─── check_runs ────────────────────────────────────────────────────── |
| 117 | // External-system create dedupe: lookup by (repo, head_sha, name, |
| 118 | // external_id). NULL external_id never matches via this query. |
| 119 | func (q *Queries) GetCheckRunByExternalID(ctx context.Context, db DBTX, arg GetCheckRunByExternalIDParams) (CheckRun, error) { |
| 120 | row := db.QueryRow(ctx, getCheckRunByExternalID, |
| 121 | arg.RepoID, |
| 122 | arg.HeadSha, |
| 123 | arg.Name, |
| 124 | arg.ExternalID, |
| 125 | ) |
| 126 | var i CheckRun |
| 127 | err := row.Scan( |
| 128 | &i.ID, |
| 129 | &i.SuiteID, |
| 130 | &i.RepoID, |
| 131 | &i.HeadSha, |
| 132 | &i.Name, |
| 133 | &i.Status, |
| 134 | &i.Conclusion, |
| 135 | &i.StartedAt, |
| 136 | &i.CompletedAt, |
| 137 | &i.DetailsUrl, |
| 138 | &i.Output, |
| 139 | &i.ExternalID, |
| 140 | &i.CreatedAt, |
| 141 | &i.UpdatedAt, |
| 142 | ) |
| 143 | return i, err |
| 144 | } |
| 145 | |
| 146 | const getCheckSuite = `-- name: GetCheckSuite :one |
| 147 | SELECT id, repo_id, head_sha, app_slug, status, conclusion, created_at, updated_at FROM check_suites WHERE id = $1 |
| 148 | ` |
| 149 | |
| 150 | func (q *Queries) GetCheckSuite(ctx context.Context, db DBTX, id int64) (CheckSuite, error) { |
| 151 | row := db.QueryRow(ctx, getCheckSuite, id) |
| 152 | var i CheckSuite |
| 153 | err := row.Scan( |
| 154 | &i.ID, |
| 155 | &i.RepoID, |
| 156 | &i.HeadSha, |
| 157 | &i.AppSlug, |
| 158 | &i.Status, |
| 159 | &i.Conclusion, |
| 160 | &i.CreatedAt, |
| 161 | &i.UpdatedAt, |
| 162 | ) |
| 163 | return i, err |
| 164 | } |
| 165 | |
| 166 | const getCheckSuiteForRepo = `-- name: GetCheckSuiteForRepo :one |
| 167 | SELECT |
| 168 | cs.id, cs.repo_id, cs.head_sha, cs.app_slug, cs.status, cs.conclusion, cs.created_at, cs.updated_at, |
| 169 | COALESCE(pr_meta.number, 0)::bigint AS pull_number, |
| 170 | COALESCE(pr_meta.title, '')::text AS pull_title, |
| 171 | COALESCE(pr_meta.author_username, '')::text AS pull_author_username, |
| 172 | COALESCE(pr_meta.head_ref, '')::text AS head_ref, |
| 173 | COALESCE(pr_meta.base_ref, '')::text AS base_ref |
| 174 | FROM check_suites cs |
| 175 | LEFT JOIN LATERAL ( |
| 176 | SELECT |
| 177 | i.number, |
| 178 | i.title, |
| 179 | COALESCE(u.username, '') AS author_username, |
| 180 | pr.head_ref, |
| 181 | pr.base_ref |
| 182 | FROM pull_requests pr |
| 183 | JOIN issues i ON i.id = pr.issue_id AND i.kind = 'pr' |
| 184 | LEFT JOIN users u ON u.id = i.author_user_id |
| 185 | WHERE i.repo_id = cs.repo_id |
| 186 | AND pr.head_oid = cs.head_sha |
| 187 | ORDER BY i.updated_at DESC, i.number DESC |
| 188 | LIMIT 1 |
| 189 | ) pr_meta ON true |
| 190 | WHERE cs.repo_id = $1 AND cs.id = $2 |
| 191 | ` |
| 192 | |
| 193 | type GetCheckSuiteForRepoParams struct { |
| 194 | RepoID int64 |
| 195 | ID int64 |
| 196 | } |
| 197 | |
| 198 | type GetCheckSuiteForRepoRow struct { |
| 199 | ID int64 |
| 200 | RepoID int64 |
| 201 | HeadSha string |
| 202 | AppSlug string |
| 203 | Status CheckStatus |
| 204 | Conclusion NullCheckConclusion |
| 205 | CreatedAt pgtype.Timestamptz |
| 206 | UpdatedAt pgtype.Timestamptz |
| 207 | PullNumber int64 |
| 208 | PullTitle string |
| 209 | PullAuthorUsername string |
| 210 | HeadRef string |
| 211 | BaseRef string |
| 212 | } |
| 213 | |
| 214 | func (q *Queries) GetCheckSuiteForRepo(ctx context.Context, db DBTX, arg GetCheckSuiteForRepoParams) (GetCheckSuiteForRepoRow, error) { |
| 215 | row := db.QueryRow(ctx, getCheckSuiteForRepo, arg.RepoID, arg.ID) |
| 216 | var i GetCheckSuiteForRepoRow |
| 217 | err := row.Scan( |
| 218 | &i.ID, |
| 219 | &i.RepoID, |
| 220 | &i.HeadSha, |
| 221 | &i.AppSlug, |
| 222 | &i.Status, |
| 223 | &i.Conclusion, |
| 224 | &i.CreatedAt, |
| 225 | &i.UpdatedAt, |
| 226 | &i.PullNumber, |
| 227 | &i.PullTitle, |
| 228 | &i.PullAuthorUsername, |
| 229 | &i.HeadRef, |
| 230 | &i.BaseRef, |
| 231 | ) |
| 232 | return i, err |
| 233 | } |
| 234 | |
| 235 | const getLatestCheckRunByName = `-- name: GetLatestCheckRunByName :one |
| 236 | SELECT id, suite_id, repo_id, head_sha, name, status, conclusion, started_at, completed_at, details_url, output, external_id, created_at, updated_at FROM check_runs |
| 237 | WHERE repo_id = $1 AND head_sha = $2 AND name = $3 |
| 238 | ORDER BY created_at DESC |
| 239 | LIMIT 1 |
| 240 | ` |
| 241 | |
| 242 | type GetLatestCheckRunByNameParams struct { |
| 243 | RepoID int64 |
| 244 | HeadSha string |
| 245 | Name string |
| 246 | } |
| 247 | |
| 248 | // Required-check evaluator: most recent run with the given name on the |
| 249 | // specified head_sha. |
| 250 | func (q *Queries) GetLatestCheckRunByName(ctx context.Context, db DBTX, arg GetLatestCheckRunByNameParams) (CheckRun, error) { |
| 251 | row := db.QueryRow(ctx, getLatestCheckRunByName, arg.RepoID, arg.HeadSha, arg.Name) |
| 252 | var i CheckRun |
| 253 | err := row.Scan( |
| 254 | &i.ID, |
| 255 | &i.SuiteID, |
| 256 | &i.RepoID, |
| 257 | &i.HeadSha, |
| 258 | &i.Name, |
| 259 | &i.Status, |
| 260 | &i.Conclusion, |
| 261 | &i.StartedAt, |
| 262 | &i.CompletedAt, |
| 263 | &i.DetailsUrl, |
| 264 | &i.Output, |
| 265 | &i.ExternalID, |
| 266 | &i.CreatedAt, |
| 267 | &i.UpdatedAt, |
| 268 | ) |
| 269 | return i, err |
| 270 | } |
| 271 | |
| 272 | const getOrCreateCheckSuite = `-- name: GetOrCreateCheckSuite :one |
| 273 | |
| 274 | |
| 275 | INSERT INTO check_suites (repo_id, head_sha, app_slug) |
| 276 | VALUES ($1, $2, $3) |
| 277 | ON CONFLICT (repo_id, head_sha, app_slug) DO UPDATE |
| 278 | SET app_slug = EXCLUDED.app_slug |
| 279 | RETURNING id, repo_id, head_sha, app_slug, status, conclusion, created_at, updated_at |
| 280 | ` |
| 281 | |
| 282 | type GetOrCreateCheckSuiteParams struct { |
| 283 | RepoID int64 |
| 284 | HeadSha string |
| 285 | AppSlug string |
| 286 | } |
| 287 | |
| 288 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 289 | // ─── check_suites ──────────────────────────────────────────────────── |
| 290 | // Idempotent suite-by-(repo, head_sha, app_slug) lookup. Used by every |
| 291 | // check-run create so consumers don't need to manage suite ids. ON |
| 292 | // CONFLICT … DO UPDATE returns the existing row when the unique |
| 293 | // (repo_id, head_sha, app_slug) already exists; otherwise returns the |
| 294 | // freshly inserted one. |
| 295 | func (q *Queries) GetOrCreateCheckSuite(ctx context.Context, db DBTX, arg GetOrCreateCheckSuiteParams) (CheckSuite, error) { |
| 296 | row := db.QueryRow(ctx, getOrCreateCheckSuite, arg.RepoID, arg.HeadSha, arg.AppSlug) |
| 297 | var i CheckSuite |
| 298 | err := row.Scan( |
| 299 | &i.ID, |
| 300 | &i.RepoID, |
| 301 | &i.HeadSha, |
| 302 | &i.AppSlug, |
| 303 | &i.Status, |
| 304 | &i.Conclusion, |
| 305 | &i.CreatedAt, |
| 306 | &i.UpdatedAt, |
| 307 | ) |
| 308 | return i, err |
| 309 | } |
| 310 | |
| 311 | const listCheckRunsBySuite = `-- name: ListCheckRunsBySuite :many |
| 312 | SELECT id, suite_id, repo_id, head_sha, name, status, conclusion, started_at, completed_at, details_url, output, external_id, created_at, updated_at FROM check_runs |
| 313 | WHERE suite_id = $1 |
| 314 | ORDER BY name |
| 315 | ` |
| 316 | |
| 317 | func (q *Queries) ListCheckRunsBySuite(ctx context.Context, db DBTX, suiteID int64) ([]CheckRun, error) { |
| 318 | rows, err := db.Query(ctx, listCheckRunsBySuite, suiteID) |
| 319 | if err != nil { |
| 320 | return nil, err |
| 321 | } |
| 322 | defer rows.Close() |
| 323 | items := []CheckRun{} |
| 324 | for rows.Next() { |
| 325 | var i CheckRun |
| 326 | if err := rows.Scan( |
| 327 | &i.ID, |
| 328 | &i.SuiteID, |
| 329 | &i.RepoID, |
| 330 | &i.HeadSha, |
| 331 | &i.Name, |
| 332 | &i.Status, |
| 333 | &i.Conclusion, |
| 334 | &i.StartedAt, |
| 335 | &i.CompletedAt, |
| 336 | &i.DetailsUrl, |
| 337 | &i.Output, |
| 338 | &i.ExternalID, |
| 339 | &i.CreatedAt, |
| 340 | &i.UpdatedAt, |
| 341 | ); err != nil { |
| 342 | return nil, err |
| 343 | } |
| 344 | items = append(items, i) |
| 345 | } |
| 346 | if err := rows.Err(); err != nil { |
| 347 | return nil, err |
| 348 | } |
| 349 | return items, nil |
| 350 | } |
| 351 | |
| 352 | const listCheckRunsForCommit = `-- name: ListCheckRunsForCommit :many |
| 353 | SELECT id, suite_id, repo_id, head_sha, name, status, conclusion, started_at, completed_at, details_url, output, external_id, created_at, updated_at FROM check_runs |
| 354 | WHERE repo_id = $1 AND head_sha = $2 |
| 355 | ORDER BY name |
| 356 | ` |
| 357 | |
| 358 | type ListCheckRunsForCommitParams struct { |
| 359 | RepoID int64 |
| 360 | HeadSha string |
| 361 | } |
| 362 | |
| 363 | func (q *Queries) ListCheckRunsForCommit(ctx context.Context, db DBTX, arg ListCheckRunsForCommitParams) ([]CheckRun, error) { |
| 364 | rows, err := db.Query(ctx, listCheckRunsForCommit, arg.RepoID, arg.HeadSha) |
| 365 | if err != nil { |
| 366 | return nil, err |
| 367 | } |
| 368 | defer rows.Close() |
| 369 | items := []CheckRun{} |
| 370 | for rows.Next() { |
| 371 | var i CheckRun |
| 372 | if err := rows.Scan( |
| 373 | &i.ID, |
| 374 | &i.SuiteID, |
| 375 | &i.RepoID, |
| 376 | &i.HeadSha, |
| 377 | &i.Name, |
| 378 | &i.Status, |
| 379 | &i.Conclusion, |
| 380 | &i.StartedAt, |
| 381 | &i.CompletedAt, |
| 382 | &i.DetailsUrl, |
| 383 | &i.Output, |
| 384 | &i.ExternalID, |
| 385 | &i.CreatedAt, |
| 386 | &i.UpdatedAt, |
| 387 | ); err != nil { |
| 388 | return nil, err |
| 389 | } |
| 390 | items = append(items, i) |
| 391 | } |
| 392 | if err := rows.Err(); err != nil { |
| 393 | return nil, err |
| 394 | } |
| 395 | return items, nil |
| 396 | } |
| 397 | |
| 398 | const listCheckSuiteIDsForHead = `-- name: ListCheckSuiteIDsForHead :many |
| 399 | SELECT id FROM check_suites |
| 400 | WHERE repo_id = $1 AND head_sha = $2 AND status <> 'completed' |
| 401 | ` |
| 402 | |
| 403 | type ListCheckSuiteIDsForHeadParams struct { |
| 404 | RepoID int64 |
| 405 | HeadSha string |
| 406 | } |
| 407 | |
| 408 | // Used by the stale-on-push hook to flip queued/in_progress suites on |
| 409 | // the previous head to conclusion='stale'. |
| 410 | func (q *Queries) ListCheckSuiteIDsForHead(ctx context.Context, db DBTX, arg ListCheckSuiteIDsForHeadParams) ([]int64, error) { |
| 411 | rows, err := db.Query(ctx, listCheckSuiteIDsForHead, arg.RepoID, arg.HeadSha) |
| 412 | if err != nil { |
| 413 | return nil, err |
| 414 | } |
| 415 | defer rows.Close() |
| 416 | items := []int64{} |
| 417 | for rows.Next() { |
| 418 | var id int64 |
| 419 | if err := rows.Scan(&id); err != nil { |
| 420 | return nil, err |
| 421 | } |
| 422 | items = append(items, id) |
| 423 | } |
| 424 | if err := rows.Err(); err != nil { |
| 425 | return nil, err |
| 426 | } |
| 427 | return items, nil |
| 428 | } |
| 429 | |
| 430 | const listCheckSuitesForCommit = `-- name: ListCheckSuitesForCommit :many |
| 431 | SELECT id, repo_id, head_sha, app_slug, status, conclusion, created_at, updated_at FROM check_suites |
| 432 | WHERE repo_id = $1 AND head_sha = $2 |
| 433 | ORDER BY app_slug |
| 434 | ` |
| 435 | |
| 436 | type ListCheckSuitesForCommitParams struct { |
| 437 | RepoID int64 |
| 438 | HeadSha string |
| 439 | } |
| 440 | |
| 441 | func (q *Queries) ListCheckSuitesForCommit(ctx context.Context, db DBTX, arg ListCheckSuitesForCommitParams) ([]CheckSuite, error) { |
| 442 | rows, err := db.Query(ctx, listCheckSuitesForCommit, arg.RepoID, arg.HeadSha) |
| 443 | if err != nil { |
| 444 | return nil, err |
| 445 | } |
| 446 | defer rows.Close() |
| 447 | items := []CheckSuite{} |
| 448 | for rows.Next() { |
| 449 | var i CheckSuite |
| 450 | if err := rows.Scan( |
| 451 | &i.ID, |
| 452 | &i.RepoID, |
| 453 | &i.HeadSha, |
| 454 | &i.AppSlug, |
| 455 | &i.Status, |
| 456 | &i.Conclusion, |
| 457 | &i.CreatedAt, |
| 458 | &i.UpdatedAt, |
| 459 | ); err != nil { |
| 460 | return nil, err |
| 461 | } |
| 462 | items = append(items, i) |
| 463 | } |
| 464 | if err := rows.Err(); err != nil { |
| 465 | return nil, err |
| 466 | } |
| 467 | return items, nil |
| 468 | } |
| 469 | |
| 470 | const listCheckSuitesForRepo = `-- name: ListCheckSuitesForRepo :many |
| 471 | SELECT |
| 472 | cs.id, cs.repo_id, cs.head_sha, cs.app_slug, cs.status, cs.conclusion, cs.created_at, cs.updated_at, |
| 473 | COALESCE(pr_meta.number, 0)::bigint AS pull_number, |
| 474 | COALESCE(pr_meta.title, '')::text AS pull_title, |
| 475 | COALESCE(pr_meta.author_username, '')::text AS pull_author_username, |
| 476 | COALESCE(pr_meta.head_ref, '')::text AS head_ref, |
| 477 | COALESCE(pr_meta.base_ref, '')::text AS base_ref |
| 478 | FROM check_suites cs |
| 479 | LEFT JOIN LATERAL ( |
| 480 | SELECT |
| 481 | i.number, |
| 482 | i.title, |
| 483 | COALESCE(u.username, '') AS author_username, |
| 484 | pr.head_ref, |
| 485 | pr.base_ref |
| 486 | FROM pull_requests pr |
| 487 | JOIN issues i ON i.id = pr.issue_id AND i.kind = 'pr' |
| 488 | LEFT JOIN users u ON u.id = i.author_user_id |
| 489 | WHERE i.repo_id = cs.repo_id |
| 490 | AND pr.head_oid = cs.head_sha |
| 491 | ORDER BY i.updated_at DESC, i.number DESC |
| 492 | LIMIT 1 |
| 493 | ) pr_meta ON true |
| 494 | WHERE cs.repo_id = $1 |
| 495 | ORDER BY cs.updated_at DESC, cs.id DESC |
| 496 | LIMIT $2 OFFSET $3 |
| 497 | ` |
| 498 | |
| 499 | type ListCheckSuitesForRepoParams struct { |
| 500 | RepoID int64 |
| 501 | Limit int32 |
| 502 | Offset int32 |
| 503 | } |
| 504 | |
| 505 | type ListCheckSuitesForRepoRow struct { |
| 506 | ID int64 |
| 507 | RepoID int64 |
| 508 | HeadSha string |
| 509 | AppSlug string |
| 510 | Status CheckStatus |
| 511 | Conclusion NullCheckConclusion |
| 512 | CreatedAt pgtype.Timestamptz |
| 513 | UpdatedAt pgtype.Timestamptz |
| 514 | PullNumber int64 |
| 515 | PullTitle string |
| 516 | PullAuthorUsername string |
| 517 | HeadRef string |
| 518 | BaseRef string |
| 519 | } |
| 520 | |
| 521 | func (q *Queries) ListCheckSuitesForRepo(ctx context.Context, db DBTX, arg ListCheckSuitesForRepoParams) ([]ListCheckSuitesForRepoRow, error) { |
| 522 | rows, err := db.Query(ctx, listCheckSuitesForRepo, arg.RepoID, arg.Limit, arg.Offset) |
| 523 | if err != nil { |
| 524 | return nil, err |
| 525 | } |
| 526 | defer rows.Close() |
| 527 | items := []ListCheckSuitesForRepoRow{} |
| 528 | for rows.Next() { |
| 529 | var i ListCheckSuitesForRepoRow |
| 530 | if err := rows.Scan( |
| 531 | &i.ID, |
| 532 | &i.RepoID, |
| 533 | &i.HeadSha, |
| 534 | &i.AppSlug, |
| 535 | &i.Status, |
| 536 | &i.Conclusion, |
| 537 | &i.CreatedAt, |
| 538 | &i.UpdatedAt, |
| 539 | &i.PullNumber, |
| 540 | &i.PullTitle, |
| 541 | &i.PullAuthorUsername, |
| 542 | &i.HeadRef, |
| 543 | &i.BaseRef, |
| 544 | ); err != nil { |
| 545 | return nil, err |
| 546 | } |
| 547 | items = append(items, i) |
| 548 | } |
| 549 | if err := rows.Err(); err != nil { |
| 550 | return nil, err |
| 551 | } |
| 552 | return items, nil |
| 553 | } |
| 554 | |
| 555 | const markCheckSuiteStale = `-- name: MarkCheckSuiteStale :exec |
| 556 | UPDATE check_suites |
| 557 | SET status = 'completed', conclusion = 'stale' |
| 558 | WHERE id = $1 |
| 559 | ` |
| 560 | |
| 561 | func (q *Queries) MarkCheckSuiteStale(ctx context.Context, db DBTX, id int64) error { |
| 562 | _, err := db.Exec(ctx, markCheckSuiteStale, id) |
| 563 | return err |
| 564 | } |
| 565 | |
| 566 | const updateCheckRun = `-- name: UpdateCheckRun :exec |
| 567 | UPDATE check_runs |
| 568 | SET status = $2, |
| 569 | conclusion = $5::check_conclusion, |
| 570 | started_at = $6::timestamptz, |
| 571 | completed_at = $7::timestamptz, |
| 572 | details_url = $3, |
| 573 | output = $4 |
| 574 | WHERE id = $1 |
| 575 | ` |
| 576 | |
| 577 | type UpdateCheckRunParams struct { |
| 578 | ID int64 |
| 579 | Status CheckStatus |
| 580 | DetailsUrl string |
| 581 | Output []byte |
| 582 | Conclusion NullCheckConclusion |
| 583 | StartedAt pgtype.Timestamptz |
| 584 | CompletedAt pgtype.Timestamptz |
| 585 | } |
| 586 | |
| 587 | func (q *Queries) UpdateCheckRun(ctx context.Context, db DBTX, arg UpdateCheckRunParams) error { |
| 588 | _, err := db.Exec(ctx, updateCheckRun, |
| 589 | arg.ID, |
| 590 | arg.Status, |
| 591 | arg.DetailsUrl, |
| 592 | arg.Output, |
| 593 | arg.Conclusion, |
| 594 | arg.StartedAt, |
| 595 | arg.CompletedAt, |
| 596 | ) |
| 597 | return err |
| 598 | } |
| 599 | |
| 600 | const updateCheckSuiteRollup = `-- name: UpdateCheckSuiteRollup :exec |
| 601 | UPDATE check_suites |
| 602 | SET status = $2, |
| 603 | conclusion = $3::check_conclusion |
| 604 | WHERE id = $1 |
| 605 | ` |
| 606 | |
| 607 | type UpdateCheckSuiteRollupParams struct { |
| 608 | ID int64 |
| 609 | Status CheckStatus |
| 610 | Conclusion NullCheckConclusion |
| 611 | } |
| 612 | |
| 613 | // Persists the rollup result computed in Go (suite_rollup.go). |
| 614 | func (q *Queries) UpdateCheckSuiteRollup(ctx context.Context, db DBTX, arg UpdateCheckSuiteRollupParams) error { |
| 615 | _, err := db.Exec(ctx, updateCheckSuiteRollup, arg.ID, arg.Status, arg.Conclusion) |
| 616 | return err |
| 617 | } |
| 618 |