fix: trend_windows now upserts instead of accumulating (7.5GB→4MB), add competitive signal retention cleanup

This commit is contained in:
Celes Renata
2026-04-16 14:32:24 +00:00
parent 58a8726306
commit 6bab199159
3 changed files with 64 additions and 0 deletions
+12
View File
@@ -716,6 +716,18 @@ INSERT INTO trend_windows (
$9::jsonb, $10::jsonb, $11,
$12::jsonb, $13::jsonb, $14
)
ON CONFLICT (entity_type, entity_id, "window") DO UPDATE SET
trend_direction = EXCLUDED.trend_direction,
trend_strength = EXCLUDED.trend_strength,
confidence = EXCLUDED.confidence,
top_supporting_evidence = EXCLUDED.top_supporting_evidence,
top_opposing_evidence = EXCLUDED.top_opposing_evidence,
dominant_catalysts = EXCLUDED.dominant_catalysts,
material_risks = EXCLUDED.material_risks,
contradiction_score = EXCLUDED.contradiction_score,
disagreement_details = EXCLUDED.disagreement_details,
market_context = EXCLUDED.market_context,
generated_at = EXCLUDED.generated_at
RETURNING id
"""