From 29e031715535384a19171e40a899b2d60e5b5f4c Mon Sep 17 00:00:00 2001 From: skycurtain Date: Thu, 8 Oct 2026 15:32:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20=E6=95=B0=E6=8D=AE=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E4=BB=85=E7=BB=9F=E8=AE=A1=20active=20key=EF=BC=8C?= =?UTF-8?q?=E5=81=9C=E7=94=A8=20key=20=E4=B8=8D=E6=8B=89=E6=85=A2=E5=85=A8?= =?UTF-8?q?=E6=B1=A0=E6=B0=B4=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/server/src/routes/admin-usage.ts | 1 + packages/db/src/repos.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/server/src/routes/admin-usage.ts b/apps/server/src/routes/admin-usage.ts index 7c5738f..6ebb33d 100644 --- a/apps/server/src/routes/admin-usage.ts +++ b/apps/server/src/routes/admin-usage.ts @@ -240,6 +240,7 @@ export function adminUsageRoutes() { }; b.key_count += 1; if ( + v.status === "active" && v.log_synced_at && (b.cutoff === null || v.log_synced_at < b.cutoff) ) { diff --git a/packages/db/src/repos.ts b/packages/db/src/repos.ts index a7f1496..ec6743a 100644 --- a/packages/db/src/repos.ts +++ b/packages/db/src/repos.ts @@ -636,12 +636,17 @@ export function createRepos(db: Db) { }, keysExtra: { - /** 全池数据截止 = 最慢 log_synced_at */ + /** 全池数据截止 = 仍会同步的 key 中最慢 log_synced_at(停用 key 不计) */ async slowestLogSyncedAt(): Promise { const rows = await db .select({ t: sql`min(${apiKeys.log_synced_at})::text` }) .from(apiKeys) - .where(sql`${apiKeys.log_synced_at} is not null`); + .where( + and( + eq(apiKeys.status, "active"), + sql`${apiKeys.log_synced_at} is not null`, + ), + ); const raw = rows[0]?.t; if (!raw) return null; const d = new Date(raw);