diff --git a/src/app/dashboard/kpis/page.tsx b/src/app/dashboard/kpis/page.tsx index e42561b..2526862 100644 --- a/src/app/dashboard/kpis/page.tsx +++ b/src/app/dashboard/kpis/page.tsx @@ -20,11 +20,9 @@ import { isAgencyRole, serviceHeaders, supabaseUrl, userRole } from '@/lib/agenc export const dynamic = 'force-dynamic'; -/** 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 -); +/** Enough history for YoY from Jan 2025 (inclusive). No artificial 700d floor. */ +const AD_DAILY_LOOKBACK_DAYS = + Math.ceil((Date.now() - Date.UTC(2025, 0, 1)) / 86400000) + 14; const AD_DAILY_PAGE = 1000; async function fetchAdDaily( diff --git a/src/lib/ad-creatives-google.ts b/src/lib/ad-creatives-google.ts index 16114ab..23908c6 100644 --- a/src/lib/ad-creatives-google.ts +++ b/src/lib/ad-creatives-google.ts @@ -217,7 +217,7 @@ function cardsFromDaily( })); } -/** Warehouse-only Google cards (fast path). */ +/** Warehouse-only Google cards (fast path for creatives API). */ export function buildGoogleCardsFromDaily( dailyRows: Parameters[0], since: string, diff --git a/src/lib/ad-creatives-meta.ts b/src/lib/ad-creatives-meta.ts index a3b28f7..f73784f 100644 --- a/src/lib/ad-creatives-meta.ts +++ b/src/lib/ad-creatives-meta.ts @@ -851,38 +851,6 @@ async function fetchMetaCreativeCardsInner( return { ads: out }; } -/** Google cards from ad_daily only (text fallback). */ -export function buildGoogleCardsFromDaily( - dailyRows: Parameters[0], - since: string, - until: string, - limit = 40 -): AdCreativeCard[] { - return aggregateDailyByAd(dailyRows, 'google', since, until) - .slice(0, limit) - .map((agg) => ({ - platform: 'google' as const, - adId: agg.adId, - adName: agg.adName, - campaignName: agg.campaignName, - spend: Math.round(agg.spend * 100) / 100, - impressions: agg.impressions, - clicks: agg.clicks, - conversions: agg.conversions, - cpl: agg.conversions > 0 ? agg.spend / agg.conversions : null, - mediaType: 'rsa', - thumbnailUrl: '', - imageUrl: '', - headline: agg.adName, - primaryText: agg.campaignName, - headlines: agg.adName ? [agg.adName] : [], - bodies: [], - descriptions: agg.campaignName ? [agg.campaignName] : [], - assets: [], - status: undefined, - })); -} - /** * Account-level Meta clicks for the period: * - clicks = todos (Ads Manager)