* Return a language's parked (status='failed') refs to the pending set — * all of them, or only those naming one of `segments` as a dotted part * (`x`, `a.x`, `x.b`, `.x`).
(language: Language, segments?: string[], files?: Set<string>)
| 5521 | * (`x`, `a.x`, `x.b`, `.x`). |
| 5522 | */ |
| 5523 | requeueFailedReferencesByLanguage(language: Language, segments?: string[], files?: Set<string>): number { |
| 5524 | const sql = "UPDATE unresolved_refs SET status = 'pending' WHERE status = 'failed' AND language = ?"; |
| 5525 | if (!segments) return this.db.prepare(sql).run(language).changes; |
| 5526 | if (segments.length === 0) return 0; |
| 5527 | // One read of the parked rows, matched here, then an update by id. |
| 5528 | const wanted = new Set(segments); |
| 5529 | const ids = ( |
| 5530 | this.db |
| 5531 | .prepare("SELECT id, reference_name, file_path FROM unresolved_refs WHERE status = 'failed' AND language = ?") |
| 5532 | .all(language) as Array<{ id: number; reference_name: string; file_path: string }> |
| 5533 | ) |
| 5534 | .filter((r) => r.reference_name.split('.').some((seg) => wanted.has(seg))) |
| 5535 | .map((r) => { |
| 5536 | files?.add(r.file_path); |
| 5537 | return r.id; |
| 5538 | }); |
| 5539 | let changed = 0; |
| 5540 | this.db.transaction(() => { |
| 5541 | for (let i = 0; i < ids.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 5542 | const chunk = ids.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 5543 | changed += this.db |
| 5544 | .prepare(`UPDATE unresolved_refs SET status = 'pending' WHERE id IN (${chunk.map(() => '?').join(',')})`) |
| 5545 | .run(...chunk).changes; |
| 5546 | } |
| 5547 | })(); |
| 5548 | return changed; |
| 5549 | } |
| 5550 | |
| 5551 | /** Delete edges by primary key — the rebind pass's half of a re-resolution. */ |
| 5552 | deleteEdgesByIds(edgeIds: number[]): number { |
no test coverage detected