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

Method getFileReachCounts

src/db/queries.ts:3304–3324  ·  view source on GitHub ↗

* How far each of the given files reaches OUT: distinct other files its * symbols touch, and how many references that is. * * The mirror of getFileDependentCounts, and the same reasoning about * `contains` and same-file edges applies. It is driven from `nodes` rather * than fr

(filePaths: string[])

Source from the content-addressed store, hash-verified

3302 * tenth of it.
3303 */
3304 getFileReachCounts(filePaths: string[]): Array<{ filePath: string; reaches: number; refs: number }> {
3305 if (filePaths.length === 0) return [];
3306 return this.db
3307 .prepare(
3308 `SELECT sn.file_path AS filePath,
3309 COUNT(DISTINCT tn.file_path) AS reaches,
3310 COUNT(*) AS refs
3311 FROM nodes sn
3312 JOIN edges e ON e.source = sn.id
3313 JOIN nodes tn ON tn.id = e.target
3314 WHERE sn.file_path IN (SELECT value FROM json_each(?))
3315 AND e.kind != 'contains'
3316 AND tn.file_path <> sn.file_path
3317 GROUP BY sn.file_path`
3318 )
3319 .all(JSON.stringify(filePaths)) as Array<{
3320 filePath: string;
3321 reaches: number;
3322 refs: number;
3323 }>;
3324 }
3325
3326 /**
3327 * The `file` nodes for the given paths, in one query.

Callers 1

testFilesFunction · 0.45

Calls 2

allMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected