From 950ff03f7eb72fcc8af387a5ce510cda1a31f263 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Mon, 20 Apr 2026 07:12:13 +0000 Subject: [PATCH] fix: join through document_intelligence in patterns endpoint The inline catalyst_type query in GET /api/patterns/{ticker} referenced dir.document_id which does not exist on document_impact_records. The table links to documents via intelligence_id -> document_intelligence -> document_id. Added the missing JOIN to match the pattern used in _SELF_PATTERN_QUERY. --- services/api/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/api/app.py b/services/api/app.py index 2feff26..d19fbc5 100644 --- a/services/api/app.py +++ b/services/api/app.py @@ -2717,7 +2717,8 @@ async def get_patterns_for_ticker( rows = await pool.fetch( """SELECT DISTINCT dir.catalyst_type FROM document_impact_records dir - JOIN documents d ON d.id = dir.document_id + JOIN document_intelligence di ON di.id = dir.intelligence_id + JOIN documents d ON d.id = di.document_id WHERE dir.ticker = $1 AND d.status != 'rejected' AND dir.catalyst_type IS NOT NULL""",