From d97510c2d2c0ecba5495f95b974be4270debc030 Mon Sep 17 00:00:00 2001 From: Tom Ruff Date: Mon, 23 Jun 2025 13:19:48 +0300 Subject: [PATCH] Update app/api/admin/reset-all/route.ts --- app/api/admin/reset-all/route.ts | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/app/api/admin/reset-all/route.ts b/app/api/admin/reset-all/route.ts index 60f0e31..b10c4ce 100644 --- a/app/api/admin/reset-all/route.ts +++ b/app/api/admin/reset-all/route.ts @@ -6,37 +6,37 @@ export async function POST(request: NextRequest) { const { adminId } = await request.json() // Check cooldown - const lastReset = (await safeQuery( - 'SELECT timestamp FROM admin_actions WHERE action_type = "reset_all" ORDER BY timestamp DESC LIMIT 1', - )) as any[] + //const lastReset = (await safeQuery( + //'SELECT timestamp FROM admin_actions WHERE action_type = "reset_all" ORDER BY timestamp DESC LIMIT 1', + //)) as any[] - if (lastReset.length > 0) { - const lastResetTime = new Date(lastReset[0].timestamp).getTime() - const now = new Date().getTime() - const cooldownMs = 2 * 60 * 10 // 2 minutes in milliseconds + //if (lastReset.length > 0) { + //const lastResetTime = new Date(lastReset[0].timestamp).getTime() + //const now = new Date().getTime() + //const cooldownMs = 2 * 60 * 10 // 2 minutes in milliseconds - const timeSinceReset = now - lastResetTime + //const timeSinceReset = now - lastResetTime - console.log("Reset cooldown check:", { - lastResetTime: new Date(lastResetTime).toISOString(), - now: new Date(now).toISOString(), - timeSinceReset: timeSinceReset, - cooldownMs: cooldownMs, - remainingMs: cooldownMs - timeSinceReset, - }) + //console.log("Reset cooldown check:", { + //lastResetTime: new Date(lastResetTime).toISOString(), + //now: new Date(now).toISOString(), + //timeSinceReset: timeSinceReset, + //cooldownMs: cooldownMs, + //remainingMs: cooldownMs - timeSinceReset, + //}) - if (timeSinceReset < cooldownMs) { - const remainingSeconds = Math.ceil((cooldownMs - timeSinceReset) / 10) - return NextResponse.json( - { - error: `יש להמתין ${remainingSeconds} שניות בין איפוסים`, - remainingSeconds, - cooldownMs, - }, - { status: 429 }, - ) - } - } + //if (timeSinceReset < cooldownMs) { + //const remainingSeconds = Math.ceil((cooldownMs - timeSinceReset) / 10) + //return NextResponse.json( + //{ + //error: `יש להמתין ${remainingSeconds} שניות בין איפוסים`, + //remainingSeconds, + //cooldownMs, + //}, + //{ status: 429 }, + //) + //} + //} // Reset ALL users' statuses including admins, but exclude locked users const result = await safeQuery("UPDATE users SET in_shelter = NULL, last_updated = NULL WHERE lock_status = FALSE")