diff options
| author | Jeff Carr <[email protected]> | 2025-10-16 15:18:04 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-16 15:18:04 -0500 |
| commit | 9a0089928e713a35b4a5c0ab46b86fd1a2e498da (patch) | |
| tree | d8d91e8d9797f3222bcfd8d244c137e34eaadbd5 | |
| parent | 43599276915dbcef6f941aa31cfea9cc2c2512aa (diff) | |
try to sort by time. didn't work
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | stat.SortCtime.go | 32 | ||||
| -rw-r--r-- | stat.TableLimit.go | 20 | ||||
| -rw-r--r-- | stat.proto | 4 | ||||
| -rw-r--r-- | tableStats.go | 17 |
5 files changed, 70 insertions, 5 deletions
@@ -1,4 +1,4 @@ -all: proto vet +all: goimports proto vet proto: autogenpb --proto stat.proto diff --git a/stat.SortCtime.go b/stat.SortCtime.go new file mode 100644 index 0000000..ccf4b48 --- /dev/null +++ b/stat.SortCtime.go @@ -0,0 +1,32 @@ +// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. +// go install go.wit.com/apps/autogenpb@latest +// +// This file was autogenerated with autogenpb: +// autogenpb v0.5.27 Built on 2025/10/16 17:13:05 ( 52 m) +// Theese sort.pb.go and marshal.pb.go files are autogenerated +// The autogenpb sources have example .proto files with instructions +// + +package gitpb + +import ( + "sort" +) + +func (pb *Stats) SortCtime() { + statMu.Lock() + defer statMu.Unlock() + + sort.Sort(sortStatCtime(pb.Stats)) +} + +// sort struct by Ctime +type sortStatCtime []*Stat + +func (a sortStatCtime) Len() int { return len(a) } +func (a sortStatCtime) Less(i, j int) bool { + itime := a[i].Ctime.AsTime() + jtime := a[j].Ctime.AsTime() + return itime.Before(jtime) +} +func (a sortStatCtime) Swap(i, j int) { a[i], a[j] = a[j], a[i] } diff --git a/stat.TableLimit.go b/stat.TableLimit.go new file mode 100644 index 0000000..8c0b217 --- /dev/null +++ b/stat.TableLimit.go @@ -0,0 +1,20 @@ +// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. +// go install go.wit.com/apps/autogenpb@latest +// +// This file was autogenerated with autogenpb: +// autogenpb v0.5.26-2-gf383ca1 Built on 2025/10/16 13:59:01 ( 54 s) +// Theese sort.pb.go and marshal.pb.go files are autogenerated +// The autogenpb sources have example .proto files with instructions +// + +package gitpb + +import ( + "go.wit.com/lib/cobol" +) + +// formats & prints the table as text to Stdout. a real timesaver! +func (t *StatsTable) PrintTableLimit(limit int) { + t.MakeTable() + cobol.PrintTableLimit(t.pb, limit) +} @@ -13,9 +13,9 @@ message Stat { REMOTE = 2; TAG = 3; } - string patchId = 1; // `autogenpb:unique` // git hash + string patchId = 1; // `autogenpb:unique` `autogenpb:sort` string hash = 2; // `autogenpb:unique` // git hash - google.protobuf.Timestamp ctime = 3; // ctime for the .git/config file + google.protobuf.Timestamp ctime = 3; // `autogenpb:unique` `autogenpb:sort` string name = 4; // string remote = 5; // blank unless REMOTE RefType type = 6; // is set by git as the master branch diff --git a/tableStats.go b/tableStats.go index ba45e31..0a278e0 100644 --- a/tableStats.go +++ b/tableStats.go @@ -3,15 +3,24 @@ package gitpb import ( - "go.wit.com/log" "go.wit.com/lib/cobol" + "go.wit.com/log" ) func (pb *Stats) PrintTable() string { t := pb.MakeTable("missing repos table") + // limit the number of lines t.PrintTable() - return log.Sprintf("pb.StatsTB: total=(%d)", pb.Len()) + return log.Sprintf("pb.StatsTB: top 16 refs total=(%d)", pb.Len()) +} + +func (pb *Stats) PrintTableLimit(limit int) string { + t := pb.MakeTable("missing repos table") + + // limit the number of lines + t.PrintTableLimit(limit) + return log.Sprintf("pb.StatsTB: top %d refs total=(%d)", limit, pb.Len()) } func (pb *Stats) MakeTable(name string) *StatsTable { @@ -23,6 +32,10 @@ func (pb *Stats) MakeTable(name string) *StatsTable { col = t.AddPatchId() col.Width = 10 + col = t.AddHash() + col.Width = 10 + col.Header.Name = "Git Hash" + col = t.AddStringFunc("something", func(r *Stat) string { return "notsure" }) |
