fix(analytics): catalog-gap — ignore rows where pcat never evaluated

'No catalog — identified as X' rows produced during a pcat cold-pool
skip, transport blip, or open circuit breaker are not evidence of a
coverage gap; counting them raises false brand-gap insights (Audi,
2026-06-11). Excludes rows carrying the new pcat_skipped /
pcat_transient markers (sase.tr dev fd78957) or pcat_circuit_open.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Semih
2026-06-11 11:50:45 +03:00
parent 9c10513fde
commit 76ef20ec4c

View File

@@ -45,6 +45,13 @@ export async function detectCatalogCoverageGaps(
WHERE success = false
AND created_at > ${since}
AND error_message LIKE 'No catalog%'
-- pcat never definitively evaluated these (cold-pool fast-fail, transport
-- blip, or open circuit breaker) — "No catalog" here may just mean pcat
-- was skipped, not that the brand is uncovered. Counting them raises
-- false brand-gap insights (Audi, 2026-06-11).
AND (timings->>'pcat_skipped') IS DISTINCT FROM '1'
AND (timings->>'pcat_transient') IS DISTINCT FROM '1'
AND (timings->>'pcat_circuit_open') IS DISTINCT FROM 'true'
)
SELECT
initcap(split_part(label, ' ', 1)) AS brand,