displayStatsTable displays workflow statistics in a sorted table
(statsList []*WorkflowStats)
| 246 | |
| 247 | // displayStatsTable displays workflow statistics in a sorted table |
| 248 | func displayStatsTable(statsList []*WorkflowStats) { |
| 249 | if len(statsList) == 0 { |
| 250 | return |
| 251 | } |
| 252 | |
| 253 | compileStatsLog.Printf("Displaying stats table: workflow_count=%d", len(statsList)) |
| 254 | |
| 255 | // Sort by file size (descending) |
| 256 | slices.SortFunc(statsList, func(a, b *WorkflowStats) int { |
| 257 | if a.FileSize > b.FileSize { |
| 258 | return -1 |
| 259 | } |
| 260 | if a.FileSize < b.FileSize { |
| 261 | return 1 |
| 262 | } |
| 263 | return 0 |
| 264 | }) |
| 265 | |
| 266 | // Calculate totals |
| 267 | totalSize := int64(0) |
| 268 | totalJobs := 0 |
| 269 | totalSteps := 0 |
| 270 | totalScripts := 0 |
| 271 | totalScriptSize := 0 |
| 272 | |
| 273 | for _, stats := range statsList { |
| 274 | totalSize += stats.FileSize |
| 275 | totalJobs += stats.Jobs |
| 276 | totalSteps += stats.Steps |
| 277 | totalScripts += stats.ScriptCount |
| 278 | totalScriptSize += stats.ScriptSize |
| 279 | } |
| 280 | |
| 281 | // Limit display to top 10 workflows by size |
| 282 | displayCount := len(statsList) |
| 283 | const maxDisplay = 10 |
| 284 | if displayCount > maxDisplay { |
| 285 | displayCount = maxDisplay |
| 286 | } |
| 287 | |
| 288 | // Build table rows |
| 289 | rows := make([][]string, 0, displayCount) |
| 290 | for i, stats := range statsList { |
| 291 | if i >= maxDisplay { |
| 292 | break |
| 293 | } |
| 294 | // Check if workflow is above 500KB (512000 bytes) |
| 295 | const maxSize = 500 * 1024 |
| 296 | workflowName := stats.Workflow |
| 297 | fileSize := console.FormatFileSize(stats.FileSize) |
| 298 | |
| 299 | if stats.FileSize > maxSize { |
| 300 | // Apply red color and error icon for large workflows |
| 301 | if tty.IsStderrTerminal() { |
| 302 | workflowName = styles.Error.Render("✗ ") + styles.Error.Render(stats.Workflow) |
| 303 | fileSize = styles.Error.Render(console.FormatFileSize(stats.FileSize)) |
| 304 | } else { |
| 305 | // In non-TTY mode, just add the icon without color |