(table *tview.Table, pools []metrics.MetricsPool, scaleSets []metrics.MetricsScaleSet)
| 612 | } |
| 613 | |
| 614 | func renderPoolsTable(table *tview.Table, pools []metrics.MetricsPool, scaleSets []metrics.MetricsScaleSet) { |
| 615 | table.Clear() |
| 616 | |
| 617 | headers := []string{"NAME", "PROVIDER", "OS", "RUNNERS", "CAP", "STATUS"} |
| 618 | for i, h := range headers { |
| 619 | cell := tview.NewTableCell(h). |
| 620 | SetTextColor(tcell.ColorYellow). |
| 621 | SetSelectable(false). |
| 622 | SetExpansion(1) |
| 623 | if i >= 3 { |
| 624 | cell.SetAlign(tview.AlignRight) |
| 625 | } |
| 626 | table.SetCell(0, i, cell) |
| 627 | } |
| 628 | |
| 629 | row := 1 |
| 630 | |
| 631 | sortedPools := make([]metrics.MetricsPool, len(pools)) |
| 632 | copy(sortedPools, pools) |
| 633 | sort.Slice(sortedPools, func(i, j int) bool { |
| 634 | if sortedPools[i].Enabled != sortedPools[j].Enabled { |
| 635 | return sortedPools[i].Enabled |
| 636 | } |
| 637 | ci := sumCounts(sortedPools[i].RunnerCounts) |
| 638 | cj := sumCounts(sortedPools[j].RunnerCounts) |
| 639 | return ci > cj |
| 640 | }) |
| 641 | |
| 642 | for _, p := range sortedPools { |
| 643 | name := topPoolDisplayName(p) |
| 644 | current := sumCounts(p.RunnerCounts) |
| 645 | maxRunners := int(p.MaxRunners) |
| 646 | utilization := 0 |
| 647 | if maxRunners > 0 { |
| 648 | utilization = current * 100 / maxRunners |
| 649 | } |
| 650 | |
| 651 | runnersStr := fmt.Sprintf("%d/%d", current, maxRunners) |
| 652 | capStr := fmt.Sprintf("%d%%", utilization) |
| 653 | capColor := tcell.ColorGreen |
| 654 | if utilization >= 90 { |
| 655 | capColor = tcell.ColorRed |
| 656 | } else if utilization >= 70 { |
| 657 | capColor = tcell.ColorYellow |
| 658 | } |
| 659 | |
| 660 | statusStr := "enabled" |
| 661 | statusColor := tcell.ColorGreen |
| 662 | nameColor := tcell.ColorWhite |
| 663 | if !p.Enabled { |
| 664 | statusStr = "disabled" |
| 665 | statusColor = tcell.ColorGray |
| 666 | nameColor = tcell.ColorGray |
| 667 | } |
| 668 | |
| 669 | table.SetCell(row, 0, tview.NewTableCell(name).SetTextColor(nameColor).SetExpansion(1)) |
| 670 | table.SetCell(row, 1, tview.NewTableCell(p.ProviderName).SetExpansion(1)) |
| 671 | table.SetCell(row, 2, tview.NewTableCell(p.OSType).SetExpansion(1)) |
no test coverage detected