From 3870959747c13246441a0e4e79503e030176736b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 10 Mar 2025 17:24:06 -0500 Subject: [PATCH] fix patches stats --- windowPatches.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/windowPatches.go b/windowPatches.go index 5735872..95c3b74 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -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