From d1a26269bc71df4dc4125cd08a537dbe49b655fc Mon Sep 17 00:00:00 2001 From: olsch01 Date: Mon, 23 Mar 2026 15:08:00 -0400 Subject: [PATCH] Fix Performance page showing empty data The trends and snapshots endpoints returned periodLabel ("last_30_days") as the date field, which parseISO() couldn't parse, causing all records to be filtered out. Now uses capturedAt timestamp for date filtering and display. Co-Authored-By: Claude Opus 4.6 --- apps/api/src/routes/performance.ts | 1 + apps/frontend/src/pages/Performance.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/api/src/routes/performance.ts b/apps/api/src/routes/performance.ts index 2d9c9d7..aec7b75 100644 --- a/apps/api/src/routes/performance.ts +++ b/apps/api/src/routes/performance.ts @@ -123,6 +123,7 @@ export default async function (fastify: FastifyInstance) { const rows = await db .select({ date: performanceSnapshots.periodLabel, + capturedAt: performanceSnapshots.capturedAt, platformId: performanceSnapshots.platformId, viewsSearch: performanceSnapshots.viewsSearch, viewsListing: performanceSnapshots.viewsListing, diff --git a/apps/frontend/src/pages/Performance.tsx b/apps/frontend/src/pages/Performance.tsx index 8a7fe4b..3c68906 100644 --- a/apps/frontend/src/pages/Performance.tsx +++ b/apps/frontend/src/pages/Performance.tsx @@ -206,7 +206,7 @@ export default function Performance() { const trends: TrendPoint[] = rawTrends?.length ? rawTrends.map((r: any) => ({ - date: r.date || r.periodLabel, + date: r.capturedAt ? r.capturedAt.split('T')[0].split(' ')[0] : r.date || r.periodLabel, platform: r.platformId || r.platform, views_search: Number(r.viewsSearch ?? r.views_search ?? 0), conversion_rate: Number(r.conversionRate ?? r.conversion_rate ?? 0), @@ -217,7 +217,7 @@ export default function Performance() { : MOCK_TRENDS; const snapshots: SnapshotRow[] = rawSnapshots?.length ? rawSnapshots.map((r: any) => ({ - date: r.periodLabel || r.date, + date: r.capturedAt ? r.capturedAt.split('T')[0].split(' ')[0] : r.periodLabel || r.date, platform: r.platformId || r.platform, views: Number(r.viewsSearch ?? r.views ?? 0), clicks: Number(r.viewsListing ?? r.clicks ?? 0),