From fc7083d95e67b6b7f59108c7014c4fc4d437600d Mon Sep 17 00:00:00 2001 From: Felipe Coutinho Date: Sat, 17 Jan 2026 16:56:05 +0000 Subject: [PATCH] perf(dashboard): usar Promise.all para fetching paralelo de dados Co-Authored-By: Claude Opus 4.5 --- app/(dashboard)/dashboard/page.tsx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/(dashboard)/dashboard/page.tsx b/app/(dashboard)/dashboard/page.tsx index 9388929..01066b6 100644 --- a/app/(dashboard)/dashboard/page.tsx +++ b/app/(dashboard)/dashboard/page.tsx @@ -29,25 +29,22 @@ export default async function Page({ searchParams }: PageProps) { const periodoParam = getSingleParam(resolvedSearchParams, "periodo"); const { period: selectedPeriod } = parsePeriodParam(periodoParam); - const data = await fetchDashboardData(user.id, selectedPeriod); - - // Buscar preferências do usuário - const preferencesResult = await db - .select({ - disableMagnetlines: schema.userPreferences.disableMagnetlines, - }) - .from(schema.userPreferences) - .where(eq(schema.userPreferences.userId, user.id)) - .limit(1); + const [data, preferencesResult] = await Promise.all([ + fetchDashboardData(user.id, selectedPeriod), + db + .select({ + disableMagnetlines: schema.userPreferences.disableMagnetlines, + }) + .from(schema.userPreferences) + .where(eq(schema.userPreferences.userId, user.id)) + .limit(1), + ]); const disableMagnetlines = preferencesResult[0]?.disableMagnetlines ?? false; return (
- +