MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / countIncomingEdges

Method countIncomingEdges

src/db/queries.ts:2836–2855  ·  view source on GitHub ↗

* 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[])

Source from the content-addressed store, hash-verified

2834 * edges" from "not asked about".
2835 */
2836 countIncomingEdges(ids: readonly string[]): Map<string, number> {
2837 const out = new Map<string, number>();
2838 if (ids.length === 0) return out;
2839 const unique = [...new Set(ids)];
2840 for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2841 const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2842 const placeholders = chunk.map(() => '?').join(',');
2843 const rows = this.db
2844 .prepare(
2845 // A test's request onto a route (tier-synthesizer's `test-request`)
2846 // is not a production caller: forty tests hitting one endpoint must
2847 // not make it a hub the Steps walk refuses to enter.
2848 `SELECT target, COUNT(*) AS count FROM edges WHERE target IN (${placeholders})
2849 AND (metadata IS NULL OR metadata NOT LIKE '%"synthesizedBy":"test-request"%') GROUP BY target`
2850 )
2851 .all(...chunk) as Array<{ target: string; count: number }>;
2852 for (const row of rows) out.set(row.target, row.count);
2853 }
2854 return out;
2855 }
2856
2857 /**
2858 * Incoming edges for MANY target nodes in one query — the mirror of

Callers 1

getFanInMethod · 0.80

Calls 5

mapMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65
joinMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected