cmd/ismdb: use trainer id from dump when available
This commit is contained in:
+5
-2
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -21,7 +22,7 @@ func main() {
|
|||||||
)
|
)
|
||||||
flag.StringVar(&uri, "db", "idle_single_mode.sqlite3", "output database `URI` or filename")
|
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.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.TextVar(&logLevel, "log", slog.LevelInfo, "log `level`")
|
||||||
flag.Func("d", "`dir`ectory containing idle single mode dumps to load (repeatable)", func(s string) error {
|
flag.Func("d", "`dir`ectory containing idle single mode dumps to load (repeatable)", func(s string) error {
|
||||||
es, err := os.ReadDir(s)
|
es, err := os.ReadDir(s)
|
||||||
@@ -62,7 +63,9 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Debug("insert")
|
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 {
|
if err != nil {
|
||||||
log.Error("insert", slog.Any("err", err))
|
log.Error("insert", slog.Any("err", err))
|
||||||
continue
|
continue
|
||||||
|
|||||||
+6
-1
@@ -340,9 +340,14 @@ type ProgressInfo struct {
|
|||||||
StoryEventCharaBonuses []umadump.Never `json:"story_event_chara_bonus_list"`
|
StoryEventCharaBonuses []umadump.Never `json:"story_event_chara_bonus_list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Extra struct {
|
||||||
|
ViewerID int64 `json:"viewer_id"`
|
||||||
|
TrainedChara map[string]any `json:"trained_chara"`
|
||||||
|
}
|
||||||
|
|
||||||
type WorkIdleSingleMode struct {
|
type WorkIdleSingleMode struct {
|
||||||
ProgressInfo ProgressInfo `json:"progress_info"`
|
ProgressInfo ProgressInfo `json:"progress_info"`
|
||||||
ProgressLog IdleSingleModeProgressLog `json:"progress_log_info"`
|
ProgressLog IdleSingleModeProgressLog `json:"progress_log_info"`
|
||||||
End End `json:"end_info"`
|
End End `json:"end_info"`
|
||||||
Extra map[string]any `json:"extra_data"`
|
Extra Extra `json:"extra_data"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user