重构:将 "lobster" 重命名为 "claw" 并添加国际化支持 (i18n)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { gte, sql } from "drizzle-orm";
|
||||
import { db } from "@/lib/db";
|
||||
import { lobsters, tasks } from "@/lib/db/schema";
|
||||
import { claws, tasks } from "@/lib/db/schema";
|
||||
import {
|
||||
redis,
|
||||
getGlobalStats,
|
||||
@@ -23,16 +23,16 @@ export async function GET() {
|
||||
|
||||
const now = Date.now();
|
||||
const fiveMinutesAgo = now - 300_000;
|
||||
const activeLobsters = await redis.zcount(
|
||||
"active:lobsters",
|
||||
const activeClaws = await redis.zcount(
|
||||
"active:claws",
|
||||
fiveMinutesAgo,
|
||||
"+inf"
|
||||
);
|
||||
|
||||
const totalLobstersResult = await db
|
||||
const totalClawsResult = await db
|
||||
.select({ count: sql<number>`count(*)` })
|
||||
.from(lobsters);
|
||||
const totalLobsters = totalLobstersResult[0]?.count ?? 0;
|
||||
.from(claws);
|
||||
const totalClaws = totalClawsResult[0]?.count ?? 0;
|
||||
|
||||
const todayStart = new Date();
|
||||
todayStart.setHours(0, 0, 0, 0);
|
||||
@@ -58,8 +58,8 @@ export async function GET() {
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
totalLobsters,
|
||||
activeLobsters,
|
||||
totalClaws,
|
||||
activeClaws,
|
||||
tasksToday,
|
||||
tasksTotal: parseInt(globalStats.total_tasks ?? "0", 10),
|
||||
avgTaskDuration,
|
||||
|
||||
Reference in New Issue
Block a user