feat: add configurable user statistics

This commit is contained in:
chuan
2026-08-22 22:42:06 +08:00
parent a9727e9b96
commit 74b5994180
18 changed files with 210 additions and 33 deletions
+2
View File
@@ -128,6 +128,7 @@ CREATE TABLE IF NOT EXISTS managed_keys (
route_mode TEXT NOT NULL CHECK(route_mode IN ('auto', 'strict')),
upstream_account_id TEXT NOT NULL DEFAULT '',
all_models INTEGER NOT NULL DEFAULT 1,
show_in_stats INTEGER NOT NULL DEFAULT 1,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
@@ -292,6 +293,7 @@ func OpenSQLiteUsage(databasePath string) (*SQLiteUsageRepository, error) {
`ALTER TABLE model_prices ADD COLUMN source_fetched_at TEXT NOT NULL DEFAULT ''`,
`ALTER TABLE billing_accounts ADD COLUMN lifetime_spent_micros INTEGER NOT NULL DEFAULT 0`,
`ALTER TABLE upstream_accounts ADD COLUMN current INTEGER NOT NULL DEFAULT 1`,
`ALTER TABLE managed_keys ADD COLUMN show_in_stats INTEGER NOT NULL DEFAULT 1`,
} {
if _, err := db.Exec(migration); err != nil && !strings.Contains(strings.ToLower(err.Error()), "duplicate column") {
_ = db.Close()