From 199f59e81b7ffef0b4e59f61d0cf6cb5b835c684 Mon Sep 17 00:00:00 2001 From: ArshVermaGit Date: Mon, 1 Jun 2026 04:22:48 +0530 Subject: [PATCH] fix(api): return 500 error on local-coding-stats database failure --- src/app/api/local-coding/stats/route.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/api/local-coding/stats/route.ts b/src/app/api/local-coding/stats/route.ts index c1e5cd4e..be722998 100644 --- a/src/app/api/local-coding/stats/route.ts +++ b/src/app/api/local-coding/stats/route.ts @@ -40,12 +40,11 @@ export async function GET(req: NextRequest) { .order("date", { ascending: false }); if (error) { - // Table may not exist in all deployments — degrade gracefully - return Response.json({ - dailyData: [], - totals: { totalSeconds: 0, totalDays: 0, avgSecondsPerDay: 0 }, - hasData: false, - }); + console.error("Failed to fetch local coding stats:", error); + return Response.json( + { error: "Failed to fetch local coding stats" }, + { status: 500 } + ); } if (!sessions || sessions.length === 0) {