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

Method getIncomingEdgesTo

src/db/queries.ts:2896–2913  ·  view source on GitHub ↗

* Incoming edges for MANY target nodes in one query — the mirror of * getOutgoingEdgesFrom. Needed wherever a whole file's inbound edges * are wanted at once ("which files import anything in this one?").

(targetIds: readonly string[], kinds?: EdgeKind[])

Source from the content-addressed store, hash-verified

2894 * are wanted at once ("which files import anything in this one?").
2895 */
2896 getIncomingEdgesTo(targetIds: readonly string[], kinds?: EdgeKind[]): Edge[] {
2897 if (targetIds.length === 0) return [];
2898 const unique = [...new Set(targetIds)];
2899 const out: Edge[] = [];
2900 for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
2901 const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
2902 const placeholders = chunk.map(() => '?').join(',');
2903 let sql = `SELECT * FROM edges WHERE target IN (${placeholders})`;
2904 const params: string[] = [...chunk];
2905 if (kinds && kinds.length > 0) {
2906 sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`;
2907 params.push(...kinds);
2908 }
2909 const rows = this.db.prepare(sql).all(...params) as EdgeRow[];
2910 for (const row of rows) out.push(rowToEdge(row));
2911 }
2912 return out;
2913 }
2914
2915 /**
2916 * Fan-out (total outgoing edge count) for MANY nodes in one query — the

Callers 8

buildFileFunction · 0.45
buildScreensFunction · 0.45
attributeFunction · 0.45
mentionsOfFunction · 0.45
renderParentsFunction · 0.45
hierarchyEdgesFunction · 0.45
countImplementersFunction · 0.45
containersOfFunction · 0.45

Calls 6

rowToEdgeFunction · 0.85
mapMethod · 0.80
pushMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected