* 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[])
| 3336 | * tenth of it. |
| 3337 | */ |
| 3338 | getFileReachCounts(filePaths: string[]): Array<{ filePath: string; reaches: number; refs: number }> { |
| 3339 | if (filePaths.length === 0) return []; |
| 3340 | return this.db |
| 3341 | .prepare( |
| 3342 | `SELECT sn.file_path AS filePath, |
| 3343 | COUNT(DISTINCT tn.file_path) AS reaches, |
| 3344 | COUNT(*) AS refs |
| 3345 | FROM nodes sn |
| 3346 | JOIN edges e ON e.source = sn.id |
| 3347 | JOIN nodes tn ON tn.id = e.target |
| 3348 | WHERE sn.file_path IN (SELECT value FROM json_each(?)) |
| 3349 | AND e.kind != 'contains' |
| 3350 | AND tn.file_path <> sn.file_path |
| 3351 | GROUP BY sn.file_path` |
| 3352 | ) |
| 3353 | .all(JSON.stringify(filePaths)) as Array<{ |
| 3354 | filePath: string; |
| 3355 | reaches: number; |
| 3356 | refs: number; |
| 3357 | }>; |
| 3358 | } |
| 3359 | |
| 3360 | /** |
| 3361 | * The `file` nodes for the given paths, in one query. |