78521fe12 days ago21 lines · 707 B| 1 | import { type Database, schema } from '@ghost/db'; |
| 2 | import { and, eq |
| 3 | |
| 4 | import { RepositoryImportingError } |
| 5 | |
| 6 | /** An import writes issue numbers GitHub chose, so nothing else may take one until it is done. */ |
| 7 | export async function assertNotImporting |
| 8 | db: Pick |
| 9 | repositoryId: string, |
| 10 | ) { |
| 11 | const [active] |
| 12 | .select({ id: |
| 13 | .from(schema.repositoryImport |
| 14 | .where( |
| 15 | and( |
| 16 | eq(schema.repositoryImport |
| 17 | inArray(schema.repositoryImport |
| 18 | ), |
| 19 | ); |
| 20 | if (active) throw |
| 21 | } |