@@ -80,9 +80,8 @@ export function lineageGraph(manifest: any, id: string): LineageGraph {
8080 const isTest = ( one : string ) => [ "test" , "unit_test" ] . includes ( lookup ( manifest , one ) ?. resource_type ?? one . split ( "." ) [ 0 ] )
8181 const keep = new Set ( [ id ] )
8282 // Breadth first, so a cut keeps the nearest nodes.
83- const walk = ( links : Record < string , string [ ] > , limit : number ) => {
83+ const walk = ( links : Record < string , string [ ] > , limit : number , seen = new Set ( [ id ] ) ) => {
8484 const queue = [ id ]
85- const seen = new Set ( [ id ] )
8685 let count = 0
8786 while ( queue . length ) {
8887 for ( const next of links [ queue . shift ( ) ! ] ?? [ ] ) {
@@ -97,14 +96,16 @@ export function lineageGraph(manifest: any, id: string): LineageGraph {
9796 return false
9897 }
9998 const upTruncated = walk ( parents , MAX_UPSTREAM )
100- const truncated = walk ( children , MAX_DOWNSTREAM )
99+ // Tests are counted for the target and what is downstream of it only; upstream ones would only add weight.
100+ const counted = new Set ( [ id ] )
101+ const truncated = walk ( children , MAX_DOWNSTREAM , counted )
101102 const graph : LineageGraph = { nodes : { } , parents : { } , children : { } , truncated, upTruncated }
102103 for ( const one of keep ) {
103104 graph . nodes [ one ] = nodeOf ( one , lookup ( manifest , one ) )
104105 graph . parents [ one ] = ( parents [ one ] ?? [ ] ) . filter ( ( other ) => keep . has ( other ) )
105106 graph . children [ one ] = ( children [ one ] ?? [ ] ) . filter ( ( other ) => {
106107 if ( keep . has ( other ) ) return true
107- if ( ! isTest ( other ) ) return false
108+ if ( ! isTest ( other ) || ! counted . has ( one ) ) return false
108109 if ( ! graph . nodes [ other ] ) {
109110 graph . nodes [ other ] = { ...nodeOf ( other , lookup ( manifest , other ) ) , type : "test" }
110111 graph . parents [ other ] = ( parents [ other ] ?? [ ] ) . filter ( ( p ) => keep . has ( p ) )
0 commit comments