* Fan-in (total incoming edge count) for MANY nodes in one query. * * The per-node alternative — `getIncomingEdges(id).length` — is an indexed * lookup each, but a symbol screen rendering a couple of hundred callees * would issue a couple of hundred of them. Ids with no incoming edges ar
(ids: readonly string[])
| 2868 | * edges" from "not asked about". |
| 2869 | */ |
| 2870 | countIncomingEdges(ids: readonly string[]): Map<string, number> { |
| 2871 | const out = new Map<string, number>(); |
| 2872 | if (ids.length === 0) return out; |
| 2873 | const unique = [...new Set(ids)]; |
| 2874 | for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) { |
| 2875 | const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE); |
| 2876 | const placeholders = chunk.map(() => '?').join(','); |
| 2877 | const rows = this.db |
| 2878 | .prepare( |
| 2879 | // A test's request onto a route (tier-synthesizer's `test-request`) |
| 2880 | // is not a production caller: forty tests hitting one endpoint must |
| 2881 | // not make it a hub the Steps walk refuses to enter. |
| 2882 | `SELECT target, COUNT(*) AS count FROM edges WHERE target IN (${placeholders}) |
| 2883 | AND (metadata IS NULL OR metadata NOT LIKE '%"synthesizedBy":"test-request"%') GROUP BY target` |
| 2884 | ) |
| 2885 | .all(...chunk) as Array<{ target: string; count: number }>; |
| 2886 | for (const row of rows) out.set(row.target, row.count); |
| 2887 | } |
| 2888 | return out; |
| 2889 | } |
| 2890 | |
| 2891 | /** |
| 2892 | * Incoming edges for MANY target nodes in one query — the mirror of |