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) ) );