early attempt at pb table update()
This commit is contained in:
parent
3ca7403aa6
commit
9dfcbb0432
|
@ -0,0 +1,96 @@
|
|||
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
|
||||
// This file was autogenerated with autogenpb 0.0.61 2025/02/23_0116_UTC
|
||||
// go install go.wit.com/apps/autogenpb@latest
|
||||
//
|
||||
// define which structs (messages) you want to use in the .proto file
|
||||
// Then sort.pb.go and marshal.pb.go files are autogenerated
|
||||
//
|
||||
// autogenpb uses it and has an example .proto file with instructions
|
||||
//
|
||||
|
||||
package virtpb
|
||||
|
||||
import (
|
||||
"go.wit.com/lib/protobuf/guipb"
|
||||
"go.wit.com/log"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func (mt *DropletsTable) Update() {
|
||||
log.Info("now what?")
|
||||
for _, name := range mt.pb.Order {
|
||||
log.Info("virtpb: trying to update row()", name)
|
||||
if mt.updateStringFunc(name) {
|
||||
continue
|
||||
}
|
||||
if mt.updateTimeFunc(name) {
|
||||
continue
|
||||
}
|
||||
/*
|
||||
if mt.updateIntFunc(name) {
|
||||
continue
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
func (mt *DropletsTable) updateStringFunc(name string) bool {
|
||||
log.Info("LOOKING FOR STRING row", name)
|
||||
var found *guipb.StringRow
|
||||
for i, r := range mt.pb.StringRows {
|
||||
// log.Info("could use", i, r.Header.Name, "for name =", name)
|
||||
if r.Header.Name == name {
|
||||
log.Info("found row", i, r.Header.Name)
|
||||
found = r
|
||||
break
|
||||
}
|
||||
}
|
||||
if found == nil {
|
||||
log.Info("did not find string row", name)
|
||||
return false
|
||||
}
|
||||
for _, sf := range mt.stringFuncs {
|
||||
if sf.title != name {
|
||||
continue
|
||||
}
|
||||
log.Info("updateStringFunc() has row len =", len(mt.x.Droplets))
|
||||
log.Info("virtpb: starting", name, found.Vals)
|
||||
for i, _ := range found.Vals {
|
||||
found.Vals[i] = sf.f(mt.x.Droplets[i])
|
||||
}
|
||||
log.Info("virtpb: ending", name, found.Vals)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (mt *DropletsTable) updateTimeFunc(name string) bool {
|
||||
log.Info("LOOKING FOR TIME row", name)
|
||||
var found *guipb.TimeRow
|
||||
for i, r := range mt.pb.TimeRows {
|
||||
// log.Info("could use", i, r.Header.Name, "for name =", name)
|
||||
if r.Header.Name == name {
|
||||
log.Info("found row", i, r.Header.Name)
|
||||
found = r
|
||||
break
|
||||
}
|
||||
}
|
||||
if found == nil {
|
||||
log.Info("did not find time row", name)
|
||||
return false
|
||||
}
|
||||
for _, sf := range mt.timeFuncs {
|
||||
if sf.title != name {
|
||||
continue
|
||||
}
|
||||
log.Info("updateTimeFunc() has row len =", len(mt.x.Droplets))
|
||||
log.Info("virtpb: starting", name, found.Vals)
|
||||
for i, _ := range found.Vals {
|
||||
newt := sf.f(mt.x.Droplets[i])
|
||||
found.Vals[i] = timestamppb.New(newt) // convert to protobuf time
|
||||
}
|
||||
log.Info("virtpb: ending", name, found.Vals)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
Loading…
Reference in New Issue