* Resolve and persist edges to database
(
unresolvedRefs: UnresolvedReference[],
onProgress?: (current: number, total: number) => void
)
| 1175 | * Resolve and persist edges to database |
| 1176 | */ |
| 1177 | resolveAndPersist( |
| 1178 | unresolvedRefs: UnresolvedReference[], |
| 1179 | onProgress?: (current: number, total: number) => void |
| 1180 | ): ResolutionResult { |
| 1181 | const result = this.resolveAll(unresolvedRefs, onProgress); |
| 1182 | |
| 1183 | // Create edges from resolved references |
| 1184 | const edges = this.createEdges(result.resolved); |
| 1185 | |
| 1186 | // Insert edges into database |
| 1187 | if (edges.length > 0) { |
| 1188 | this.queries.insertEdges(edges); |
| 1189 | } |
| 1190 | |
| 1191 | // Clean up resolved refs from unresolved_refs table so metrics are accurate |
| 1192 | if (result.resolved.length > 0) { |
| 1193 | const { rowIds, legacyKeys } = ReferenceResolver.partitionResolvedCleanup(result.resolved); |
| 1194 | this.queries.deleteReferencesByRowIds(rowIds); |
| 1195 | this.queries.deleteSpecificResolvedReferences(legacyKeys); |
| 1196 | } |
| 1197 | |
| 1198 | // Park unresolvable refs as status='failed' — parity with |
| 1199 | // resolveAndPersistBatched. Deleting them was wrong (#1240): a ref whose |
| 1200 | // own file never changes is otherwise gone forever, so when a DIFFERENT |
| 1201 | // file later gains the export/symbol that would satisfy it, no sync can |
| 1202 | // recreate the edge — only a full re-index. Failed rows are excluded from |
| 1203 | // the pending readers, which preserves the #1187 orphan sweep's |
| 1204 | // invariant in status form: after a COMPLETED pass nothing it processed |
| 1205 | // is still 'pending', so any pending row at rest belongs to an |
| 1206 | // interrupted run and the sweep can key off the pending count. |
| 1207 | if (result.unresolved.length > 0) { |
| 1208 | const { byRowId, legacyKeys } = ReferenceResolver.partitionFailedCleanup(result.unresolved); |
| 1209 | this.queries.markReferencesFailedByRowIds(byRowId); |
| 1210 | this.queries.markReferencesFailed(legacyKeys); |
| 1211 | } |
| 1212 | |
| 1213 | return result; |
| 1214 | } |
| 1215 | |
| 1216 | /** |
| 1217 | * Yielding counterpart of {@link resolveAndPersist} for a caller-supplied |
no test coverage detected