| 1 | // Code generated by sqlc. DO NOT EDIT. |
| 2 | // versions: |
| 3 | // sqlc v1.31.1 |
| 4 | // source: github_imports.sql |
| 5 | |
| 6 | package orgsdb |
| 7 | |
| 8 | import ( |
| 9 | "context" |
| 10 | |
| 11 | "github.com/jackc/pgx/v5/pgtype" |
| 12 | ) |
| 13 | |
| 14 | const createOrgGithubImport = `-- name: CreateOrgGithubImport :one |
| 15 | |
| 16 | INSERT INTO org_github_imports ( |
| 17 | org_id, source_org, requested_by_user_id, include_private, |
| 18 | token_present, token_ciphertext, token_nonce |
| 19 | ) VALUES ( |
| 20 | $1, $2, $5::bigint, $3, |
| 21 | $4, $6::bytea, $7::bytea |
| 22 | ) |
| 23 | RETURNING id, org_id, source_host, source_org, requested_by_user_id, status, include_private, token_present, token_ciphertext, token_nonce, total_count, last_error, started_at, completed_at, created_at, updated_at |
| 24 | ` |
| 25 | |
| 26 | type CreateOrgGithubImportParams struct { |
| 27 | OrgID int64 |
| 28 | SourceOrg string |
| 29 | IncludePrivate bool |
| 30 | TokenPresent bool |
| 31 | RequestedByUserID pgtype.Int8 |
| 32 | TokenCiphertext []byte |
| 33 | TokenNonce []byte |
| 34 | } |
| 35 | |
| 36 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 37 | func (q *Queries) CreateOrgGithubImport(ctx context.Context, db DBTX, arg CreateOrgGithubImportParams) (OrgGithubImport, error) { |
| 38 | row := db.QueryRow(ctx, createOrgGithubImport, |
| 39 | arg.OrgID, |
| 40 | arg.SourceOrg, |
| 41 | arg.IncludePrivate, |
| 42 | arg.TokenPresent, |
| 43 | arg.RequestedByUserID, |
| 44 | arg.TokenCiphertext, |
| 45 | arg.TokenNonce, |
| 46 | ) |
| 47 | var i OrgGithubImport |
| 48 | err := row.Scan( |
| 49 | &i.ID, |
| 50 | &i.OrgID, |
| 51 | &i.SourceHost, |
| 52 | &i.SourceOrg, |
| 53 | &i.RequestedByUserID, |
| 54 | &i.Status, |
| 55 | &i.IncludePrivate, |
| 56 | &i.TokenPresent, |
| 57 | &i.TokenCiphertext, |
| 58 | &i.TokenNonce, |
| 59 | &i.TotalCount, |
| 60 | &i.LastError, |
| 61 | &i.StartedAt, |
| 62 | &i.CompletedAt, |
| 63 | &i.CreatedAt, |
| 64 | &i.UpdatedAt, |
| 65 | ) |
| 66 | return i, err |
| 67 | } |
| 68 | |
| 69 | const getOrgGithubImport = `-- name: GetOrgGithubImport :one |
| 70 | SELECT id, org_id, source_host, source_org, requested_by_user_id, status, include_private, token_present, token_ciphertext, token_nonce, total_count, last_error, started_at, completed_at, created_at, updated_at FROM org_github_imports WHERE id = $1 |
| 71 | ` |
| 72 | |
| 73 | func (q *Queries) GetOrgGithubImport(ctx context.Context, db DBTX, id int64) (OrgGithubImport, error) { |
| 74 | row := db.QueryRow(ctx, getOrgGithubImport, id) |
| 75 | var i OrgGithubImport |
| 76 | err := row.Scan( |
| 77 | &i.ID, |
| 78 | &i.OrgID, |
| 79 | &i.SourceHost, |
| 80 | &i.SourceOrg, |
| 81 | &i.RequestedByUserID, |
| 82 | &i.Status, |
| 83 | &i.IncludePrivate, |
| 84 | &i.TokenPresent, |
| 85 | &i.TokenCiphertext, |
| 86 | &i.TokenNonce, |
| 87 | &i.TotalCount, |
| 88 | &i.LastError, |
| 89 | &i.StartedAt, |
| 90 | &i.CompletedAt, |
| 91 | &i.CreatedAt, |
| 92 | &i.UpdatedAt, |
| 93 | ) |
| 94 | return i, err |
| 95 | } |
| 96 | |
| 97 | const getOrgGithubImportForOrg = `-- name: GetOrgGithubImportForOrg :one |
| 98 | SELECT id, org_id, source_host, source_org, requested_by_user_id, status, include_private, token_present, token_ciphertext, token_nonce, total_count, last_error, started_at, completed_at, created_at, updated_at FROM org_github_imports |
| 99 | WHERE id = $1 AND org_id = $2 |
| 100 | ` |
| 101 | |
| 102 | type GetOrgGithubImportForOrgParams struct { |
| 103 | ID int64 |
| 104 | OrgID int64 |
| 105 | } |
| 106 | |
| 107 | func (q *Queries) GetOrgGithubImportForOrg(ctx context.Context, db DBTX, arg GetOrgGithubImportForOrgParams) (OrgGithubImport, error) { |
| 108 | row := db.QueryRow(ctx, getOrgGithubImportForOrg, arg.ID, arg.OrgID) |
| 109 | var i OrgGithubImport |
| 110 | err := row.Scan( |
| 111 | &i.ID, |
| 112 | &i.OrgID, |
| 113 | &i.SourceHost, |
| 114 | &i.SourceOrg, |
| 115 | &i.RequestedByUserID, |
| 116 | &i.Status, |
| 117 | &i.IncludePrivate, |
| 118 | &i.TokenPresent, |
| 119 | &i.TokenCiphertext, |
| 120 | &i.TokenNonce, |
| 121 | &i.TotalCount, |
| 122 | &i.LastError, |
| 123 | &i.StartedAt, |
| 124 | &i.CompletedAt, |
| 125 | &i.CreatedAt, |
| 126 | &i.UpdatedAt, |
| 127 | ) |
| 128 | return i, err |
| 129 | } |
| 130 | |
| 131 | const getOrgGithubImportProgress = `-- name: GetOrgGithubImportProgress :one |
| 132 | SELECT |
| 133 | i.id, i.org_id, i.source_host, i.source_org, i.requested_by_user_id, i.status, i.include_private, i.token_present, i.token_ciphertext, i.token_nonce, i.total_count, i.last_error, i.started_at, i.completed_at, i.created_at, i.updated_at, |
| 134 | count(r.id)::integer AS discovered_count, |
| 135 | count(r.id) FILTER (WHERE r.status = 'queued')::integer AS queued_count, |
| 136 | count(r.id) FILTER (WHERE r.status = 'importing')::integer AS importing_count, |
| 137 | count(r.id) FILTER (WHERE r.status = 'imported')::integer AS imported_count, |
| 138 | count(r.id) FILTER (WHERE r.status = 'skipped')::integer AS skipped_count, |
| 139 | count(r.id) FILTER (WHERE r.status = 'failed')::integer AS failed_count |
| 140 | FROM org_github_imports i |
| 141 | LEFT JOIN org_github_import_repos r ON r.import_id = i.id |
| 142 | WHERE i.id = $1 AND i.org_id = $2 |
| 143 | GROUP BY i.id |
| 144 | ` |
| 145 | |
| 146 | type GetOrgGithubImportProgressParams struct { |
| 147 | ID int64 |
| 148 | OrgID int64 |
| 149 | } |
| 150 | |
| 151 | type GetOrgGithubImportProgressRow struct { |
| 152 | ID int64 |
| 153 | OrgID int64 |
| 154 | SourceHost string |
| 155 | SourceOrg string |
| 156 | RequestedByUserID pgtype.Int8 |
| 157 | Status string |
| 158 | IncludePrivate bool |
| 159 | TokenPresent bool |
| 160 | TokenCiphertext []byte |
| 161 | TokenNonce []byte |
| 162 | TotalCount int32 |
| 163 | LastError pgtype.Text |
| 164 | StartedAt pgtype.Timestamptz |
| 165 | CompletedAt pgtype.Timestamptz |
| 166 | CreatedAt pgtype.Timestamptz |
| 167 | UpdatedAt pgtype.Timestamptz |
| 168 | DiscoveredCount int32 |
| 169 | QueuedCount int32 |
| 170 | ImportingCount int32 |
| 171 | ImportedCount int32 |
| 172 | SkippedCount int32 |
| 173 | FailedCount int32 |
| 174 | } |
| 175 | |
| 176 | func (q *Queries) GetOrgGithubImportProgress(ctx context.Context, db DBTX, arg GetOrgGithubImportProgressParams) (GetOrgGithubImportProgressRow, error) { |
| 177 | row := db.QueryRow(ctx, getOrgGithubImportProgress, arg.ID, arg.OrgID) |
| 178 | var i GetOrgGithubImportProgressRow |
| 179 | err := row.Scan( |
| 180 | &i.ID, |
| 181 | &i.OrgID, |
| 182 | &i.SourceHost, |
| 183 | &i.SourceOrg, |
| 184 | &i.RequestedByUserID, |
| 185 | &i.Status, |
| 186 | &i.IncludePrivate, |
| 187 | &i.TokenPresent, |
| 188 | &i.TokenCiphertext, |
| 189 | &i.TokenNonce, |
| 190 | &i.TotalCount, |
| 191 | &i.LastError, |
| 192 | &i.StartedAt, |
| 193 | &i.CompletedAt, |
| 194 | &i.CreatedAt, |
| 195 | &i.UpdatedAt, |
| 196 | &i.DiscoveredCount, |
| 197 | &i.QueuedCount, |
| 198 | &i.ImportingCount, |
| 199 | &i.ImportedCount, |
| 200 | &i.SkippedCount, |
| 201 | &i.FailedCount, |
| 202 | ) |
| 203 | return i, err |
| 204 | } |
| 205 | |
| 206 | const getOrgGithubImportRepo = `-- name: GetOrgGithubImportRepo :one |
| 207 | SELECT id, import_id, github_id, source_full_name, source_name, target_name, clone_url, description, default_branch, target_visibility, is_private, is_fork, status, repo_id, last_error, started_at, completed_at, created_at, updated_at FROM org_github_import_repos WHERE id = $1 |
| 208 | ` |
| 209 | |
| 210 | func (q *Queries) GetOrgGithubImportRepo(ctx context.Context, db DBTX, id int64) (OrgGithubImportRepo, error) { |
| 211 | row := db.QueryRow(ctx, getOrgGithubImportRepo, id) |
| 212 | var i OrgGithubImportRepo |
| 213 | err := row.Scan( |
| 214 | &i.ID, |
| 215 | &i.ImportID, |
| 216 | &i.GithubID, |
| 217 | &i.SourceFullName, |
| 218 | &i.SourceName, |
| 219 | &i.TargetName, |
| 220 | &i.CloneUrl, |
| 221 | &i.Description, |
| 222 | &i.DefaultBranch, |
| 223 | &i.TargetVisibility, |
| 224 | &i.IsPrivate, |
| 225 | &i.IsFork, |
| 226 | &i.Status, |
| 227 | &i.RepoID, |
| 228 | &i.LastError, |
| 229 | &i.StartedAt, |
| 230 | &i.CompletedAt, |
| 231 | &i.CreatedAt, |
| 232 | &i.UpdatedAt, |
| 233 | ) |
| 234 | return i, err |
| 235 | } |
| 236 | |
| 237 | const insertOrgGithubImportRepo = `-- name: InsertOrgGithubImportRepo :one |
| 238 | INSERT INTO org_github_import_repos ( |
| 239 | import_id, github_id, source_full_name, source_name, target_name, |
| 240 | clone_url, description, default_branch, target_visibility, |
| 241 | is_private, is_fork |
| 242 | ) VALUES ( |
| 243 | $1, $11::bigint, $2, $3, $4, |
| 244 | $5, $6, $7, $8, $9, $10 |
| 245 | ) |
| 246 | ON CONFLICT (import_id, target_name) DO UPDATE |
| 247 | SET github_id = EXCLUDED.github_id, |
| 248 | source_full_name = EXCLUDED.source_full_name, |
| 249 | source_name = EXCLUDED.source_name, |
| 250 | clone_url = EXCLUDED.clone_url, |
| 251 | description = EXCLUDED.description, |
| 252 | default_branch = EXCLUDED.default_branch, |
| 253 | target_visibility = EXCLUDED.target_visibility, |
| 254 | is_private = EXCLUDED.is_private, |
| 255 | is_fork = EXCLUDED.is_fork, |
| 256 | updated_at = now() |
| 257 | RETURNING id, import_id, github_id, source_full_name, source_name, target_name, clone_url, description, default_branch, target_visibility, is_private, is_fork, status, repo_id, last_error, started_at, completed_at, created_at, updated_at |
| 258 | ` |
| 259 | |
| 260 | type InsertOrgGithubImportRepoParams struct { |
| 261 | ImportID int64 |
| 262 | SourceFullName string |
| 263 | SourceName string |
| 264 | TargetName string |
| 265 | CloneUrl string |
| 266 | Description string |
| 267 | DefaultBranch string |
| 268 | TargetVisibility RepoVisibility |
| 269 | IsPrivate bool |
| 270 | IsFork bool |
| 271 | GithubID pgtype.Int8 |
| 272 | } |
| 273 | |
| 274 | func (q *Queries) InsertOrgGithubImportRepo(ctx context.Context, db DBTX, arg InsertOrgGithubImportRepoParams) (OrgGithubImportRepo, error) { |
| 275 | row := db.QueryRow(ctx, insertOrgGithubImportRepo, |
| 276 | arg.ImportID, |
| 277 | arg.SourceFullName, |
| 278 | arg.SourceName, |
| 279 | arg.TargetName, |
| 280 | arg.CloneUrl, |
| 281 | arg.Description, |
| 282 | arg.DefaultBranch, |
| 283 | arg.TargetVisibility, |
| 284 | arg.IsPrivate, |
| 285 | arg.IsFork, |
| 286 | arg.GithubID, |
| 287 | ) |
| 288 | var i OrgGithubImportRepo |
| 289 | err := row.Scan( |
| 290 | &i.ID, |
| 291 | &i.ImportID, |
| 292 | &i.GithubID, |
| 293 | &i.SourceFullName, |
| 294 | &i.SourceName, |
| 295 | &i.TargetName, |
| 296 | &i.CloneUrl, |
| 297 | &i.Description, |
| 298 | &i.DefaultBranch, |
| 299 | &i.TargetVisibility, |
| 300 | &i.IsPrivate, |
| 301 | &i.IsFork, |
| 302 | &i.Status, |
| 303 | &i.RepoID, |
| 304 | &i.LastError, |
| 305 | &i.StartedAt, |
| 306 | &i.CompletedAt, |
| 307 | &i.CreatedAt, |
| 308 | &i.UpdatedAt, |
| 309 | ) |
| 310 | return i, err |
| 311 | } |
| 312 | |
| 313 | const listOrgGithubImportRepos = `-- name: ListOrgGithubImportRepos :many |
| 314 | SELECT id, import_id, github_id, source_full_name, source_name, target_name, clone_url, description, default_branch, target_visibility, is_private, is_fork, status, repo_id, last_error, started_at, completed_at, created_at, updated_at FROM org_github_import_repos |
| 315 | WHERE import_id = $1 |
| 316 | ORDER BY source_name ASC |
| 317 | ` |
| 318 | |
| 319 | func (q *Queries) ListOrgGithubImportRepos(ctx context.Context, db DBTX, importID int64) ([]OrgGithubImportRepo, error) { |
| 320 | rows, err := db.Query(ctx, listOrgGithubImportRepos, importID) |
| 321 | if err != nil { |
| 322 | return nil, err |
| 323 | } |
| 324 | defer rows.Close() |
| 325 | items := []OrgGithubImportRepo{} |
| 326 | for rows.Next() { |
| 327 | var i OrgGithubImportRepo |
| 328 | if err := rows.Scan( |
| 329 | &i.ID, |
| 330 | &i.ImportID, |
| 331 | &i.GithubID, |
| 332 | &i.SourceFullName, |
| 333 | &i.SourceName, |
| 334 | &i.TargetName, |
| 335 | &i.CloneUrl, |
| 336 | &i.Description, |
| 337 | &i.DefaultBranch, |
| 338 | &i.TargetVisibility, |
| 339 | &i.IsPrivate, |
| 340 | &i.IsFork, |
| 341 | &i.Status, |
| 342 | &i.RepoID, |
| 343 | &i.LastError, |
| 344 | &i.StartedAt, |
| 345 | &i.CompletedAt, |
| 346 | &i.CreatedAt, |
| 347 | &i.UpdatedAt, |
| 348 | ); err != nil { |
| 349 | return nil, err |
| 350 | } |
| 351 | items = append(items, i) |
| 352 | } |
| 353 | if err := rows.Err(); err != nil { |
| 354 | return nil, err |
| 355 | } |
| 356 | return items, nil |
| 357 | } |
| 358 | |
| 359 | const listOrgGithubImportsForOrg = `-- name: ListOrgGithubImportsForOrg :many |
| 360 | SELECT id, org_id, source_host, source_org, requested_by_user_id, status, include_private, token_present, token_ciphertext, token_nonce, total_count, last_error, started_at, completed_at, created_at, updated_at FROM org_github_imports |
| 361 | WHERE org_id = $1 |
| 362 | ORDER BY created_at DESC |
| 363 | LIMIT $2 |
| 364 | ` |
| 365 | |
| 366 | type ListOrgGithubImportsForOrgParams struct { |
| 367 | OrgID int64 |
| 368 | Limit int32 |
| 369 | } |
| 370 | |
| 371 | func (q *Queries) ListOrgGithubImportsForOrg(ctx context.Context, db DBTX, arg ListOrgGithubImportsForOrgParams) ([]OrgGithubImport, error) { |
| 372 | rows, err := db.Query(ctx, listOrgGithubImportsForOrg, arg.OrgID, arg.Limit) |
| 373 | if err != nil { |
| 374 | return nil, err |
| 375 | } |
| 376 | defer rows.Close() |
| 377 | items := []OrgGithubImport{} |
| 378 | for rows.Next() { |
| 379 | var i OrgGithubImport |
| 380 | if err := rows.Scan( |
| 381 | &i.ID, |
| 382 | &i.OrgID, |
| 383 | &i.SourceHost, |
| 384 | &i.SourceOrg, |
| 385 | &i.RequestedByUserID, |
| 386 | &i.Status, |
| 387 | &i.IncludePrivate, |
| 388 | &i.TokenPresent, |
| 389 | &i.TokenCiphertext, |
| 390 | &i.TokenNonce, |
| 391 | &i.TotalCount, |
| 392 | &i.LastError, |
| 393 | &i.StartedAt, |
| 394 | &i.CompletedAt, |
| 395 | &i.CreatedAt, |
| 396 | &i.UpdatedAt, |
| 397 | ); err != nil { |
| 398 | return nil, err |
| 399 | } |
| 400 | items = append(items, i) |
| 401 | } |
| 402 | if err := rows.Err(); err != nil { |
| 403 | return nil, err |
| 404 | } |
| 405 | return items, nil |
| 406 | } |
| 407 | |
| 408 | const markOrgGithubImportCompleted = `-- name: MarkOrgGithubImportCompleted :exec |
| 409 | UPDATE org_github_imports |
| 410 | SET status = 'completed', |
| 411 | token_ciphertext = NULL, |
| 412 | token_nonce = NULL, |
| 413 | completed_at = COALESCE(completed_at, now()), |
| 414 | updated_at = now() |
| 415 | WHERE id = $1 |
| 416 | ` |
| 417 | |
| 418 | func (q *Queries) MarkOrgGithubImportCompleted(ctx context.Context, db DBTX, id int64) error { |
| 419 | _, err := db.Exec(ctx, markOrgGithubImportCompleted, id) |
| 420 | return err |
| 421 | } |
| 422 | |
| 423 | const markOrgGithubImportCompletedIfDone = `-- name: MarkOrgGithubImportCompletedIfDone :one |
| 424 | UPDATE org_github_imports AS i |
| 425 | SET status = 'completed', |
| 426 | token_ciphertext = NULL, |
| 427 | token_nonce = NULL, |
| 428 | completed_at = COALESCE(completed_at, now()), |
| 429 | updated_at = now() |
| 430 | WHERE i.id = $1 |
| 431 | AND i.status = 'importing' |
| 432 | AND NOT EXISTS ( |
| 433 | SELECT 1 |
| 434 | FROM org_github_import_repos |
| 435 | WHERE import_id = $1 |
| 436 | AND status IN ('queued', 'importing') |
| 437 | ) |
| 438 | RETURNING i.id, i.org_id, i.source_host, i.source_org, i.requested_by_user_id, i.status, i.include_private, i.token_present, i.token_ciphertext, i.token_nonce, i.total_count, i.last_error, i.started_at, i.completed_at, i.created_at, i.updated_at |
| 439 | ` |
| 440 | |
| 441 | func (q *Queries) MarkOrgGithubImportCompletedIfDone(ctx context.Context, db DBTX, id int64) (OrgGithubImport, error) { |
| 442 | row := db.QueryRow(ctx, markOrgGithubImportCompletedIfDone, id) |
| 443 | var i OrgGithubImport |
| 444 | err := row.Scan( |
| 445 | &i.ID, |
| 446 | &i.OrgID, |
| 447 | &i.SourceHost, |
| 448 | &i.SourceOrg, |
| 449 | &i.RequestedByUserID, |
| 450 | &i.Status, |
| 451 | &i.IncludePrivate, |
| 452 | &i.TokenPresent, |
| 453 | &i.TokenCiphertext, |
| 454 | &i.TokenNonce, |
| 455 | &i.TotalCount, |
| 456 | &i.LastError, |
| 457 | &i.StartedAt, |
| 458 | &i.CompletedAt, |
| 459 | &i.CreatedAt, |
| 460 | &i.UpdatedAt, |
| 461 | ) |
| 462 | return i, err |
| 463 | } |
| 464 | |
| 465 | const markOrgGithubImportDiscovering = `-- name: MarkOrgGithubImportDiscovering :exec |
| 466 | UPDATE org_github_imports |
| 467 | SET status = 'discovering', |
| 468 | started_at = COALESCE(started_at, now()), |
| 469 | last_error = NULL, |
| 470 | updated_at = now() |
| 471 | WHERE id = $1 |
| 472 | AND status IN ('queued', 'discovering') |
| 473 | ` |
| 474 | |
| 475 | func (q *Queries) MarkOrgGithubImportDiscovering(ctx context.Context, db DBTX, id int64) error { |
| 476 | _, err := db.Exec(ctx, markOrgGithubImportDiscovering, id) |
| 477 | return err |
| 478 | } |
| 479 | |
| 480 | const markOrgGithubImportFailed = `-- name: MarkOrgGithubImportFailed :exec |
| 481 | UPDATE org_github_imports |
| 482 | SET status = 'failed', |
| 483 | last_error = $2, |
| 484 | token_ciphertext = NULL, |
| 485 | token_nonce = NULL, |
| 486 | completed_at = COALESCE(completed_at, now()), |
| 487 | updated_at = now() |
| 488 | WHERE id = $1 |
| 489 | ` |
| 490 | |
| 491 | type MarkOrgGithubImportFailedParams struct { |
| 492 | ID int64 |
| 493 | LastError pgtype.Text |
| 494 | } |
| 495 | |
| 496 | func (q *Queries) MarkOrgGithubImportFailed(ctx context.Context, db DBTX, arg MarkOrgGithubImportFailedParams) error { |
| 497 | _, err := db.Exec(ctx, markOrgGithubImportFailed, arg.ID, arg.LastError) |
| 498 | return err |
| 499 | } |
| 500 | |
| 501 | const markOrgGithubImportImporting = `-- name: MarkOrgGithubImportImporting :exec |
| 502 | UPDATE org_github_imports |
| 503 | SET status = 'importing', |
| 504 | total_count = $2, |
| 505 | started_at = COALESCE(started_at, now()), |
| 506 | last_error = NULL, |
| 507 | updated_at = now() |
| 508 | WHERE id = $1 |
| 509 | AND status IN ('queued', 'discovering', 'importing') |
| 510 | ` |
| 511 | |
| 512 | type MarkOrgGithubImportImportingParams struct { |
| 513 | ID int64 |
| 514 | TotalCount int32 |
| 515 | } |
| 516 | |
| 517 | func (q *Queries) MarkOrgGithubImportImporting(ctx context.Context, db DBTX, arg MarkOrgGithubImportImportingParams) error { |
| 518 | _, err := db.Exec(ctx, markOrgGithubImportImporting, arg.ID, arg.TotalCount) |
| 519 | return err |
| 520 | } |
| 521 | |
| 522 | const markOrgGithubImportRepoFailed = `-- name: MarkOrgGithubImportRepoFailed :exec |
| 523 | UPDATE org_github_import_repos |
| 524 | SET status = 'failed', |
| 525 | repo_id = COALESCE($3::bigint, repo_id), |
| 526 | last_error = $2, |
| 527 | completed_at = COALESCE(completed_at, now()), |
| 528 | updated_at = now() |
| 529 | WHERE id = $1 |
| 530 | ` |
| 531 | |
| 532 | type MarkOrgGithubImportRepoFailedParams struct { |
| 533 | ID int64 |
| 534 | LastError pgtype.Text |
| 535 | RepoID pgtype.Int8 |
| 536 | } |
| 537 | |
| 538 | func (q *Queries) MarkOrgGithubImportRepoFailed(ctx context.Context, db DBTX, arg MarkOrgGithubImportRepoFailedParams) error { |
| 539 | _, err := db.Exec(ctx, markOrgGithubImportRepoFailed, arg.ID, arg.LastError, arg.RepoID) |
| 540 | return err |
| 541 | } |
| 542 | |
| 543 | const markOrgGithubImportRepoImported = `-- name: MarkOrgGithubImportRepoImported :exec |
| 544 | UPDATE org_github_import_repos |
| 545 | SET status = 'imported', |
| 546 | repo_id = $2, |
| 547 | last_error = NULL, |
| 548 | completed_at = COALESCE(completed_at, now()), |
| 549 | updated_at = now() |
| 550 | WHERE id = $1 |
| 551 | ` |
| 552 | |
| 553 | type MarkOrgGithubImportRepoImportedParams struct { |
| 554 | ID int64 |
| 555 | RepoID pgtype.Int8 |
| 556 | } |
| 557 | |
| 558 | func (q *Queries) MarkOrgGithubImportRepoImported(ctx context.Context, db DBTX, arg MarkOrgGithubImportRepoImportedParams) error { |
| 559 | _, err := db.Exec(ctx, markOrgGithubImportRepoImported, arg.ID, arg.RepoID) |
| 560 | return err |
| 561 | } |
| 562 | |
| 563 | const markOrgGithubImportRepoImporting = `-- name: MarkOrgGithubImportRepoImporting :exec |
| 564 | UPDATE org_github_import_repos |
| 565 | SET status = 'importing', |
| 566 | started_at = COALESCE(started_at, now()), |
| 567 | last_error = NULL, |
| 568 | updated_at = now() |
| 569 | WHERE id = $1 |
| 570 | AND status = 'queued' |
| 571 | ` |
| 572 | |
| 573 | func (q *Queries) MarkOrgGithubImportRepoImporting(ctx context.Context, db DBTX, id int64) error { |
| 574 | _, err := db.Exec(ctx, markOrgGithubImportRepoImporting, id) |
| 575 | return err |
| 576 | } |
| 577 | |
| 578 | const markOrgGithubImportRepoSkipped = `-- name: MarkOrgGithubImportRepoSkipped :exec |
| 579 | UPDATE org_github_import_repos |
| 580 | SET status = 'skipped', |
| 581 | last_error = $2, |
| 582 | completed_at = COALESCE(completed_at, now()), |
| 583 | updated_at = now() |
| 584 | WHERE id = $1 |
| 585 | ` |
| 586 | |
| 587 | type MarkOrgGithubImportRepoSkippedParams struct { |
| 588 | ID int64 |
| 589 | LastError pgtype.Text |
| 590 | } |
| 591 | |
| 592 | func (q *Queries) MarkOrgGithubImportRepoSkipped(ctx context.Context, db DBTX, arg MarkOrgGithubImportRepoSkippedParams) error { |
| 593 | _, err := db.Exec(ctx, markOrgGithubImportRepoSkipped, arg.ID, arg.LastError) |
| 594 | return err |
| 595 | } |
| 596 |