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.
This commit is contained in:
+2
-1
@@ -2717,7 +2717,8 @@ async def get_patterns_for_ticker(
|
|||||||
rows = await pool.fetch(
|
rows = await pool.fetch(
|
||||||
"""SELECT DISTINCT dir.catalyst_type
|
"""SELECT DISTINCT dir.catalyst_type
|
||||||
FROM document_impact_records dir
|
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
|
WHERE dir.ticker = $1
|
||||||
AND d.status != 'rejected'
|
AND d.status != 'rejected'
|
||||||
AND dir.catalyst_type IS NOT NULL""",
|
AND dir.catalyst_type IS NOT NULL""",
|
||||||
|
|||||||
Reference in New Issue
Block a user