* 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>)
| 5632 | * (`x`, `a.x`, `x.b`, `.x`). |
| 5633 | */ |
| 5634 | requeueFailedReferencesByLanguage(language: Language, segments?: string[], files?: Set<string>): number { |
| 5635 | const sql = "UPDATE unresolved_refs SET status = 'pending' WHERE status = 'failed' AND language = ?"; |
| 5636 | if (!segments) return this.db.prepare(sql).run(language).changes; |
| 5637 | if (segments.length === 0) return 0; |
| 5638 | // One read of the parked rows, matched here, then an update by id. |
| 5639 | const wanted = new Set(segments); |
| 5640 | const ids = ( |
| 5641 | this.db |
| 5642 | .prepare("SELECT id, reference_name, file_path FROM unresolved_refs WHERE status = 'failed' AND language = ?") |
| 5643 | .all(language) as Array<{ id: number; reference_name: string; file_path: string }> |
| 5644 | ) |
| 5645 | .filter((r) => r.reference_name.split('.').some((seg) => wanted.has(seg))) |
| 5646 | .map((r) => { |
| 5647 | files?.add(r.file_path); |
| 5648 | return r.id; |
| 5649 | }); |
| 5650 | let changed = 0; |
| 5651 | this.db.transaction(() => { |
| 5652 | for (let i = 0; i < ids.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 5653 | const chunk = ids.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 5654 | changed += this.db |
| 5655 | .prepare(`UPDATE unresolved_refs SET status = 'pending' WHERE id IN (${chunk.map(() => '?').join(',')})`) |
| 5656 | .run(...chunk).changes; |
| 5657 | } |
| 5658 | })(); |
| 5659 | return changed; |
| 5660 | } |
| 5661 | |
| 5662 | /** Delete edges by primary key — the rebind pass's half of a re-resolution. */ |
| 5663 | deleteEdgesByIds(edgeIds: number[]): number { |
no test coverage detected