perf: creatividades warehouse-first + aviso OAuth Ads Production

Carga métricas desde ad_daily al instante (mode=fast) y enriquece previews en vivo; la UI de Agencia avisa si falta scope Ads o consent Testing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
4Ventures
2026-09-29 09:35:45 +02:00
parent 939c4a3131
commit a75f3ae30c
5 changed files with 174 additions and 36 deletions

View File

@@ -217,6 +217,22 @@ function cardsFromDaily(
}));
}
/** Warehouse-only Google cards (fast path). */
export function buildGoogleCardsFromDaily(
dailyRows: Parameters<typeof aggregateDailyByAd>[0],
since: string,
until: string,
limit = 24
): AdCreativeCard[] {
return cardsFromDaily(
dailyRows,
since,
until,
limit,
'Métricas desde warehouse (sync Ads)'
);
}
/**
* Live Google creatives: Performance Max asset groups + RSA/RDA ads.
* Always falls back to ad_daily campaign cards when the API/token fails.

View File

@@ -317,6 +317,15 @@ function cleanMetaAdName(name: string): string {
}
/** Campaign-level cards from warehouse — always available, never throws. */
export function buildMetaWarehouseCards(
dailyRows: Parameters<typeof aggregateDailyByAd>[0],
since: string,
until: string,
limit = 16
): AdCreativeCard[] {
return metaCardsFromDaily(dailyRows, since, until, limit);
}
function metaCardsFromDaily(
dailyRows: Parameters<typeof aggregateDailyByAd>[0],
since: string,