@@ -395,70 +395,68 @@ func (b *Builder) renderEntityPage(
395395 description := e .GetString ("description" )
396396
397397 // Entity profile chart data (compact format for JS)
398+ // Always include metrics so empty values are visible (helps diagnose API gaps)
399+ nodeType := e .GetString ("node_type" )
398400 profileData := map [string ]interface {}{}
399- if lc := e .GetInt ("line_count" ); lc > 0 {
400- profileData ["lc" ] = lc
401- }
402- if co := e .GetInt ("call_count" ); co > 0 {
403- profileData ["co" ] = co
404- }
405- if cb := e .GetInt ("called_by_count" ); cb > 0 {
406- profileData ["cb" ] = cb
407- }
408- if ic := e .GetInt ("import_count" ); ic > 0 {
409- profileData ["ic" ] = ic
410- }
411- if ib := e .GetInt ("imported_by_count" ); ib > 0 {
412- profileData ["ib" ] = ib
413- }
414- if fn := e .GetInt ("function_count" ); fn > 0 {
415- profileData ["fn" ] = fn
416- }
417- if cl := e .GetInt ("class_count" ); cl > 0 {
418- profileData ["cl" ] = cl
419- }
420- if tc := e .GetInt ("type_count" ); tc > 0 {
421- profileData ["tc" ] = tc
422- }
423- if fc := e .GetInt ("file_count" ); fc > 0 {
424- profileData ["fc" ] = fc
401+
402+ profileData ["lc" ] = e .GetInt ("line_count" )
403+
404+ switch nodeType {
405+ case "Function" :
406+ profileData ["co" ] = e .GetInt ("call_count" )
407+ profileData ["cb" ] = e .GetInt ("called_by_count" )
408+ case "File" :
409+ profileData ["ic" ] = e .GetInt ("import_count" )
410+ profileData ["ib" ] = e .GetInt ("imported_by_count" )
411+ profileData ["fn" ] = e .GetInt ("function_count" )
412+ profileData ["cl" ] = e .GetInt ("class_count" )
413+ profileData ["tc" ] = e .GetInt ("type_count" )
414+ case "Class" , "Type" :
415+ profileData ["fn" ] = e .GetInt ("function_count" )
416+ profileData ["cb" ] = e .GetInt ("called_by_count" )
417+ case "Directory" :
418+ profileData ["fc" ] = e .GetInt ("file_count" )
419+ profileData ["fn" ] = e .GetInt ("function_count" )
420+ profileData ["cl" ] = e .GetInt ("class_count" )
421+ default :
422+ // Domain, Subdomain, etc — include whatever is available
423+ if v := e .GetInt ("function_count" ); v > 0 {
424+ profileData ["fn" ] = v
425+ }
426+ if v := e .GetInt ("file_count" ); v > 0 {
427+ profileData ["fc" ] = v
428+ }
425429 }
430+
426431 if sl := e .GetInt ("start_line" ); sl > 0 {
427432 profileData ["sl" ] = sl
428433 }
429434 if el := e .GetInt ("end_line" ); el > 0 {
430435 profileData ["el" ] = el
431436 }
437+
432438 // Edge type breakdown
433439 edgeTypes := map [string ]int {}
434- if v := e .GetInt ("import_count" ); v > 0 {
435- edgeTypes ["imports" ] = v
436- }
437- if v := e .GetInt ("imported_by_count" ); v > 0 {
438- edgeTypes ["imports" ] += v
439- }
440- if v := e .GetInt ("call_count" ); v > 0 {
441- edgeTypes ["calls" ] = v
440+ ic := e .GetInt ("import_count" )
441+ ibc := e .GetInt ("imported_by_count" )
442+ if ic + ibc > 0 {
443+ edgeTypes ["imports" ] = ic + ibc
442444 }
443- if v := e .GetInt ("called_by_count" ); v > 0 {
444- edgeTypes ["calls" ] += v
445+ co := e .GetInt ("call_count" )
446+ cbc := e .GetInt ("called_by_count" )
447+ if co + cbc > 0 {
448+ edgeTypes ["calls" ] = co + cbc
445449 }
446- if v := e .GetInt ("function_count" ); v > 0 {
447- edgeTypes ["defines" ] += v
448- }
449- if v := e .GetInt ("class_count" ); v > 0 {
450- edgeTypes ["defines" ] += v
451- }
452- if v := e .GetInt ("type_count" ); v > 0 {
453- edgeTypes ["defines" ] += v
450+ defines := e .GetInt ("function_count" ) + e .GetInt ("class_count" ) + e .GetInt ("type_count" )
451+ if defines > 0 {
452+ edgeTypes ["defines" ] = defines
454453 }
455454 if len (edgeTypes ) > 0 {
456455 profileData ["et" ] = edgeTypes
457456 }
457+
458458 var entityChartJSON []byte
459- if len (profileData ) > 0 {
460- entityChartJSON , _ = json .Marshal (profileData )
461- }
459+ entityChartJSON , _ = json .Marshal (profileData )
462460
463461 // Source code (read from workspace if available)
464462 var sourceCode , sourceLang string
0 commit comments