(client: GraphQueryClient, project: string, scoped: ScopedGraph, direction: TraceDirection,
edgeTypes: readonly string[] | undefined, signal?: AbortSignal)
| 259 | * zaehlt der Index so nicht; ohne CALLS gibt es keine Zahl. |
| 260 | */ |
| 261 | export async function frontierCallCount(client: GraphQueryClient, project: string, scoped: ScopedGraph, direction: TraceDirection, |
| 262 | edgeTypes: readonly string[] | undefined, signal?: AbortSignal): Promise<number | undefined> { |
| 263 | if (scoped.exhausted || scoped.partial || !scoped.frontier?.length || (edgeTypes && !edgeTypes.includes('CALLS'))) return undefined; |
| 264 | const frontier = new Set(scoped.frontier), byId = new Map(scoped.data.nodes.map(node => [node.id, node])); |
| 265 | const names = [...frontier].map(identity => byId.get(identity)?.qualified_name).filter((name): name is string => Boolean(name)); |
| 266 | let calls = 0; |
| 267 | for (let at = 0; at < names.length; at += BATCH_SIZE) { |
| 268 | const rows = await readGraphPages(client, project, `MATCH (n) WHERE ${anyNames('n', names.slice(at, at + BATCH_SIZE))} RETURN id(n) AS id, n.in_degree AS calls_in, n.out_degree AS calls_out`, 'id', signal); |
| 269 | for (const row of rows) { |
| 270 | if (!frontier.has(id(row.id))) continue; |
| 271 | calls += (direction !== 'outbound' ? number(row.calls_in) ?? 0 : 0) + (direction !== 'inbound' ? number(row.calls_out) ?? 0 : 0); |
| 272 | } |
| 273 | } |
| 274 | for (const edge of scoped.data.edges) { |
| 275 | if (edge.type !== 'CALLS') continue; |
| 276 | if (direction !== 'outbound' && frontier.has(edge.target)) calls -= 1; |
| 277 | if (direction !== 'inbound' && frontier.has(edge.source)) calls -= 1; |
| 278 | } |
| 279 | return Math.max(0, calls); |
| 280 | } |
| 281 | |
| 282 | /** Eine Schaetzung der naechsten Ebene, bevor sie geladen wird (K8): so viele |
| 283 | * Knoten stehen an ihrem Rand, und so viele neue brachte jeder Knoten der |
no test coverage detected