fix: KPIs leen ad_daily desde ene 2025 para YoY completo

El lookback fijo de 420 días cortaba el histórico; ahora cubre desde 2025-01-01.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
4Ventures
2026-09-28 13:02:40 +02:00
parent 83e2b59e83
commit 4a9c2139f7

View File

@@ -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(