fix: 修复发布问题
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { claws, heartbeats, tasks, tokenUsage, geoCache } from "@/lib/db/schema";
|
import { claws, heartbeats, tasks, tokenUsage, geoCache } from "@/lib/db/schema";
|
||||||
import { sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
import { redis, redisSubscriber } from "@/lib/redis";
|
import { redis } from "@/lib/redis";
|
||||||
|
|
||||||
async function clearMockData() {
|
async function clearMockData() {
|
||||||
console.log("🧹 开始清理数据...\n");
|
console.log("🧹 开始清理数据...\n");
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ const TOOLS_USED = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// 全局变量存储所有 claws
|
// 全局变量存储所有 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() {
|
async function loadClaws() {
|
||||||
const result = await db
|
const result = await db
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { claws, heartbeats, tasks, tokenUsage } from "@/lib/db/schema";
|
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";
|
import { redis } from "@/lib/redis";
|
||||||
|
|
||||||
const ACTIVE_CLAWS_KEY = "active:claws";
|
const ACTIVE_CLAWS_KEY = "active:claws";
|
||||||
@@ -80,7 +80,7 @@ async function syncRedisStats() {
|
|||||||
.where(sql`region IS NOT NULL`)
|
.where(sql`region IS NOT NULL`)
|
||||||
.groupBy(claws.region);
|
.groupBy(claws.region);
|
||||||
|
|
||||||
const regionData: Record<string, string> = {};
|
const regionData: Record<string, number> = {};
|
||||||
for (const stat of regionStats) {
|
for (const stat of regionStats) {
|
||||||
if (stat.region) {
|
if (stat.region) {
|
||||||
regionData[stat.region] = stat.count;
|
regionData[stat.region] = stat.count;
|
||||||
@@ -129,7 +129,7 @@ async function syncRedisStats() {
|
|||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
gte(heartbeats.timestamp, hourStart),
|
gte(heartbeats.timestamp, hourStart),
|
||||||
gte(hourEnd, heartbeats.timestamp)
|
lte(heartbeats.timestamp, hourEnd)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user