From 65a09f49df16454b99f6dc86376731a48bb49461 Mon Sep 17 00:00:00 2001 From: Tom Ruff Date: Mon, 23 Jun 2025 12:51:05 +0300 Subject: [PATCH] Update app/api/admin/department-reset/route.ts --- app/api/admin/department-reset/route.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/api/admin/department-reset/route.ts b/app/api/admin/department-reset/route.ts index d7b20ce..cce30df 100644 --- a/app/api/admin/department-reset/route.ts +++ b/app/api/admin/department-reset/route.ts @@ -32,13 +32,28 @@ export async function POST(request: NextRequest) { )) as any[] if (lastReset.length > 0) { + const cooldownMs = 30 * 1000 // 30 seconds const lastResetTime = new Date(lastReset[0].timestamp).getTime() const now = new Date().getTime() - const cooldownMs = 30 * 10 // 1.5 minutes for department resets + const timeSinceReset = now - lastResetTime + console.log("Department reset cooldown check:", { + lastResetTime: new Date(lastResetTime).toISOString(), + now: new Date(now).toISOString(), + timeSinceReset: timeSinceReset, + cooldownMs: cooldownMs, + remainingMs: cooldownMs - timeSinceReset, + }) - if (now - lastResetTime < cooldownMs) { - const remainingSeconds = Math.ceil((cooldownMs - (now - lastResetTime)) / 1000) - return NextResponse.json({ error: "יש להמתין 30 שניות בין איפוסי מסגרת", remainingSeconds }, { status: 429 }) + if (timeSinceReset < cooldownMs) { + const remainingSeconds = Math.ceil((cooldownMs - timeSinceReset) / 1000) + return NextResponse.json( + { + error: `יש להמתין ${remainingSeconds} שניות בין איפוסי מסגרת`, + remainingSeconds, + cooldownMs, + }, + { status: 429 }, + ) } }