* 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[])
| 3664 | * tenth of it. |
| 3665 | */ |
| 3666 | getFileReachCounts(filePaths: string[]): Array<{ filePath: string; reaches: number; refs: number }> { |
| 3667 | if (filePaths.length === 0) return []; |
| 3668 | return this.db |
| 3669 | .prepare( |
| 3670 | `SELECT sn.file_path AS filePath, |
| 3671 | COUNT(DISTINCT tn.file_path) AS reaches, |
| 3672 | COUNT(*) AS refs |
| 3673 | FROM nodes sn |
| 3674 | JOIN edges e ON e.source = sn.id |
| 3675 | JOIN nodes tn ON tn.id = e.target |
| 3676 | WHERE sn.file_path IN (SELECT value FROM json_each(?)) |
| 3677 | AND e.kind != 'contains' |
| 3678 | AND tn.file_path <> sn.file_path |
| 3679 | GROUP BY sn.file_path` |
| 3680 | ) |
| 3681 | .all(JSON.stringify(filePaths)) as Array<{ |
| 3682 | filePath: string; |
| 3683 | reaches: number; |
| 3684 | refs: number; |
| 3685 | }>; |
| 3686 | } |
| 3687 | |
| 3688 | /** |
| 3689 | * The `file` nodes for the given paths, in one query. |