From ab00443056768c8b25d0ed92f7c68c461aae4dde Mon Sep 17 00:00:00 2001 From: richarjiang Date: Mon, 16 Mar 2026 22:00:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/clear-mock-data.ts | 2 +- scripts/simulate-live-activity.ts | 2 +- scripts/sync-redis-stats.ts | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/clear-mock-data.ts b/scripts/clear-mock-data.ts index 21e675e..1bc955c 100644 --- a/scripts/clear-mock-data.ts +++ b/scripts/clear-mock-data.ts @@ -8,7 +8,7 @@ import { db } from "@/lib/db"; import { claws, heartbeats, tasks, tokenUsage, geoCache } from "@/lib/db/schema"; import { sql } from "drizzle-orm"; -import { redis, redisSubscriber } from "@/lib/redis"; +import { redis } from "@/lib/redis"; async function clearMockData() { console.log("🧹 开始清理数据...\n"); diff --git a/scripts/simulate-live-activity.ts b/scripts/simulate-live-activity.ts index 9bddaaa..52b3c5d 100644 --- a/scripts/simulate-live-activity.ts +++ b/scripts/simulate-live-activity.ts @@ -51,7 +51,7 @@ const TOOLS_USED = [ ]; // 全局变量存储所有 claws -let allClaws: { id: string; name: string; model: string; city: string | null; country: string | null }[] = []; +let allClaws: { id: string; name: string; model: string | null; city: string | null; country: string | null }[] = []; async function loadClaws() { const result = await db diff --git a/scripts/sync-redis-stats.ts b/scripts/sync-redis-stats.ts index d26e7bb..cf79aaa 100644 --- a/scripts/sync-redis-stats.ts +++ b/scripts/sync-redis-stats.ts @@ -7,7 +7,7 @@ import { db } from "@/lib/db"; import { claws, heartbeats, tasks, tokenUsage } from "@/lib/db/schema"; -import { sql, eq, and, gte } from "drizzle-orm"; +import { sql, eq, and, gte, lte } from "drizzle-orm"; import { redis } from "@/lib/redis"; const ACTIVE_CLAWS_KEY = "active:claws"; @@ -80,7 +80,7 @@ async function syncRedisStats() { .where(sql`region IS NOT NULL`) .groupBy(claws.region); - const regionData: Record = {}; + const regionData: Record = {}; for (const stat of regionStats) { if (stat.region) { regionData[stat.region] = stat.count; @@ -129,7 +129,7 @@ async function syncRedisStats() { .where( and( gte(heartbeats.timestamp, hourStart), - gte(hourEnd, heartbeats.timestamp) + lte(heartbeats.timestamp, hourEnd) ) );