From 4a9c2139f7a766caa1299aa6487463fa940457a0 Mon Sep 17 00:00:00 2001 From: 4Ventures <4ventures@MacBook-Air-de-4Ventures.local> Date: Mon, 28 Sep 2026 13:02:40 +0200 Subject: [PATCH] fix: KPIs leen ad_daily desde ene 2025 para YoY completo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El lookback fijo de 420 días cortaba el histórico; ahora cubre desde 2025-01-01. Co-authored-by: Cursor --- src/app/dashboard/kpis/page.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/dashboard/kpis/page.tsx b/src/app/dashboard/kpis/page.tsx index 3fadfa0..e42561b 100644 --- a/src/app/dashboard/kpis/page.tsx +++ b/src/app/dashboard/kpis/page.tsx @@ -20,8 +20,11 @@ import { isAgencyRole, serviceHeaders, supabaseUrl, userRole } from '@/lib/agenc export const dynamic = 'force-dynamic'; -/** Enough history for YoY on ad-level Meta rows (can be dense). */ -const AD_DAILY_LOOKBACK_DAYS = 420; +/** Enough history for YoY from Jan 2025 (inclusive). */ +const AD_DAILY_LOOKBACK_DAYS = Math.max( + 700, + Math.ceil((Date.now() - Date.UTC(2025, 0, 1)) / 86400000) + 14 +); const AD_DAILY_PAGE = 1000; async function fetchAdDaily(