Feat: player stats [WIP]

This commit is contained in:
Grail Finder
2025-07-07 13:05:07 +03:00
parent 2751b6b9dc
commit 75651d7f76
4 changed files with 77 additions and 7 deletions

View File

@ -2,7 +2,6 @@ package repos
import (
"context"
"gralias/config"
"log/slog"
"os"
"sync"
@ -20,6 +19,7 @@ type AllRepos interface {
WordCardsRepo
SettingsRepo
CardMarksRepo
PlayerStatsRepo
InitTx(ctx context.Context) (context.Context, *sqlx.Tx, error)
Close()
}
@ -32,12 +32,7 @@ type RepoProvider struct {
var RP AllRepos
func init() {
cfg := config.LoadConfigOrDefault("")
// sqlite3 has lock on write, so we need to have only one connection per whole app
// https://github.com/mattn/go-sqlite3/issues/274#issuecomment-232942571
RP = NewRepoProvider(cfg.DBPath)
}
func NewRepoProvider(pathToDB string) *RepoProvider {
db, err := sqlx.Connect("sqlite3", pathToDB)