-
Notifications
You must be signed in to change notification settings - Fork 2
Show graph stats summary after watch generates initial files #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,34 @@ type Cache struct { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FileDomain map[string]string // filePath → domain name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // GraphStats summarises what was mapped after a generate or incremental update. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type GraphStats struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SourceFiles int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Relationships int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DeadFunctionCount int // functions with no callers (proxy for unreachable code) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FromCache bool // true when data was loaded from a local cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // computeStats derives a GraphStats from a SidecarIR and its built Cache. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func computeStats(ir *api.SidecarIR, c *Cache) GraphStats { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s := GraphStats{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Relationships: len(ir.Graph.Relationships), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, n := range ir.Graph.Nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case n.HasLabel("File"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.SourceFiles++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case n.HasLabel("Function"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.Functions++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(c.Callers[n.ID]) == 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.DeadFunctionCount++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+57
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
At Line 63-66, counting raw 💡 Proposed fix func computeStats(ir *api.SidecarIR, c *Cache) GraphStats {
s := GraphStats{
Relationships: len(ir.Graph.Relationships),
}
- for _, n := range ir.Graph.Nodes {
+ if c != nil {
+ s.SourceFiles = len(c.SourceFiles())
+ }
+ for _, n := range ir.Graph.Nodes {
switch {
- case n.HasLabel("File"):
- s.SourceFiles++
case n.HasLabel("Function"):
s.Functions++
}
}
- _ = c // reserved for future per-file breakdown
return s
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // NewCache creates an empty Cache. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewCache() *Cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &Cache{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GraphStatsis missing issue-requested health metrics.The linked objective calls for cycle/dead-function visibility, but the new stats shape only includes files/functions/relationships. That leaves the feature partially delivered for the requested summary.
🤖 Prompt for AI Agents