fix patches stats

This commit is contained in:
Jeff Carr 2025-03-10 17:24:06 -05:00
parent 1b145d1f04
commit 3870959747
1 changed files with 12 additions and 9 deletions

View File

@ -4,6 +4,7 @@
package main
import (
"fmt"
"sync"
"go.wit.com/gui"
@ -30,7 +31,7 @@ func (w *stdPatchTableWin) Toggle() {
w.win.Toggle()
}
func makePatchesWin(p *forgepb.Patches) *stdPatchTableWin {
func makePatchesWin(patches *forgepb.Patches) *stdPatchTableWin {
dwin := new(stdPatchTableWin)
dwin.win = gadgets.NewGenericWindow("current patches", "patching options")
dwin.win.Custom = func() {
@ -39,16 +40,18 @@ func makePatchesWin(p *forgepb.Patches) *stdPatchTableWin {
}
grid := dwin.win.Group.RawGrid()
grid.NewLabel(fmt.Sprintf("%d", p.Len())
grid.NewLabel(fmt.Sprintf("total patches")
grid.NewLabel(fmt.Sprintf("%d", patches.Len()))
grid.NewLabel(fmt.Sprintf("total patches"))
grid.NextRow()
all := p.All()
repomap := make(map[string]int)
all := patches.All()
for all.Scan() {
repo := all.Next()
patch := all.Next()
repomap[patch.RepoNamespace] += 1
}
grid.NewLabel(fmt.Sprintf("%d", p.Len())
grid.NewLabel(fmt.Sprintf("total repos")
grid.NewLabel(fmt.Sprintf("%d", len(repomap)))
grid.NewLabel(fmt.Sprintf("total repos"))
grid.NextRow()
grid.NewButton("reload", func() {
@ -57,8 +60,8 @@ func makePatchesWin(p *forgepb.Patches) *stdPatchTableWin {
// make a box at the bottom of the window for the protobuf table
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
if p != nil {
dwin.doPatchesTable(p)
if patches != nil {
dwin.doPatchesTable(patches)
}
return dwin