fix(analytics): catalog-gap — heuristic skip-filter for pre-flag prod rows

Prod doesn't write pcat_skipped/pcat_transient yet (sase fd78957 is on
dev), so the 2026-06-11 15:31 run still raised false gaps for Audi
(10/10 rows cold-skip), Hyundai (2/3) and VW (1/3 + 2 untraceable cache
echoes). A real pcat answer needs a network round-trip, so pcat <= 10ms
means skipped — exclude those rows. Verified on prod data: the three
false brands drop below threshold, Renault/Fiat/Honda etc. unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Semih
2026-06-11 15:35:29 +03:00
parent 76ef20ec4c
commit e9275e6f44

View File

@@ -52,6 +52,12 @@ export async function detectCatalogCoverageGaps(
AND (timings->>'pcat_skipped') IS DISTINCT FROM '1' AND (timings->>'pcat_skipped') IS DISTINCT FROM '1'
AND (timings->>'pcat_transient') IS DISTINCT FROM '1' AND (timings->>'pcat_transient') IS DISTINCT FROM '1'
AND (timings->>'pcat_circuit_open') IS DISTINCT FROM 'true' AND (timings->>'pcat_circuit_open') IS DISTINCT FROM 'true'
-- Heuristic for rows written before sase.tr fd78957 ships the flags to
-- prod: a real pcat answer needs a network round-trip (100ms+), so a
-- 1-10ms pcat sub-timing means it was skipped, not that it said no.
-- (2026-06-11: 53/227 no-catalog rows were such skips, faking gaps for
-- Audi/Hyundai/VW.) Harmless to keep once the flags are live.
AND ((timings->>'pcat') IS NULL OR (timings->>'pcat')::int > 10)
) )
SELECT SELECT
initcap(split_part(label, ' ', 1)) AS brand, initcap(split_part(label, ' ', 1)) AS brand,