core: use local watch-order store

This commit is contained in:
2026-04-11 22:32:56 +02:00
parent 600698e12a
commit 9115e16334
9 changed files with 206 additions and 450 deletions

View File

@@ -16,6 +16,7 @@ import (
"mal/internal/features/auth"
"mal/internal/jikan"
"mal/internal/server"
"mal/internal/watchorder"
"mal/internal/worker"
)
@@ -39,7 +40,22 @@ func main() {
queries := database.New(db)
authService := auth.NewService(queries)
jikanClient := jikan.NewClient(queries)
watchOrderFile := os.Getenv("WATCH_ORDER_FILE")
if watchOrderFile == "" {
watchOrderFile = "./data/watch_order.json"
}
watchOrderStore := watchorder.EmptyStore()
loadedStore, err := watchorder.LoadFromFile(watchOrderFile)
if err != nil {
log.Printf("watch-order: failed to load %s: %v", watchOrderFile, err)
} else {
watchOrderStore = loadedStore
log.Printf("watch-order: loaded %d entries from %s", watchOrderStore.Len(), watchOrderFile)
}
jikanClient := jikan.NewClient(queries, watchOrderStore)
// Start background workers
relationsWorker := worker.New(queries, jikanClient)