MCPcopy Index your code
hub / github.com/deepnote/deepnote / getUpstreamBlocksForBlocksIds

Function getUpstreamBlocksForBlocksIds

packages/reactivity/src/dag-analyzer.ts:47–61  ·  view source on GitHub ↗
(dag: BlockDependencyDag, blocksIds: string[])

Source from the content-addressed store, hash-verified

45 * The method finds dependencies in upstream mode - we are filtering out nodes from the DAG that are defined after the target blocks.
46 */
47export function getUpstreamBlocksForBlocksIds(dag: BlockDependencyDag, blocksIds: string[]): string[] {
48 const targetBlocks = dag.nodes.filter(node => blocksIds.includes(node.id))
49
50 if (targetBlocks.length === 0) {
51 return []
52 }
53
54 const maxOrder = Math.max(...targetBlocks.map(node => node.order))
55 const filteredDag = {
56 ...dag,
57 nodes: dag.nodes.filter(node => node.order <= maxOrder),
58 }
59
60 return getUpstreamBlocks(filteredDag, blocksIds)
61}
62
63function getUpstreamBlocks(dag: BlockDependencyDag, blocksIds: string[], visited: Set<string> = new Set()): string[] {
64 const inputVariables = dag.nodes.filter(node => blocksIds.includes(node.id)).flatMap(node => node.inputVariables)

Callers 2

getUpstreamBlocksFunction · 0.90

Calls 1

getUpstreamBlocksFunction · 0.70

Tested by

no test coverage detected