cmd/ismdb: use trainer id from dump when available
ci/woodpecker/push/horsebot Pipeline was successful
ci/woodpecker/push/zenno Pipeline was successful

This commit is contained in:
2026-11-10 09:29:37 -05:00
parent a67353f0b6
commit e0750bd3b2
2 changed files with 11 additions and 3 deletions
+5 -2
View File
@@ -1,6 +1,7 @@
package main
import (
"cmp"
"context"
"encoding/json"
"flag"
@@ -21,7 +22,7 @@ func main() {
)
flag.StringVar(&uri, "db", "idle_single_mode.sqlite3", "output database `URI` or filename")
flag.StringVar(&journalMode, "journal", "memory", "journal `mode` to apply to database connections")
flag.Int64Var(&trainer, "t", 0, "trainer `ID` to associate with the data")
flag.Int64Var(&trainer, "t", 0, "fallback trainer `ID` to associate with the data")
flag.TextVar(&logLevel, "log", slog.LevelInfo, "log `level`")
flag.Func("d", "`dir`ectory containing idle single mode dumps to load (repeatable)", func(s string) error {
es, err := os.ReadDir(s)
@@ -62,7 +63,9 @@ func main() {
continue
}
log.Debug("insert")
err = insert(ctx, db, log, &career, trainer)
endTrainer, _ := career.Extra.TrainedChara["viewer_id"].(float64)
t := cmp.Or(career.Extra.ViewerID, int64(endTrainer), trainer)
err = insert(ctx, db, log, &career, t)
if err != nil {
log.Error("insert", slog.Any("err", err))
continue