|
|
@@ -982,7 +982,24 @@ def dashboard_concern_detail_data(concern_id: str) -> JSONResponse:
|
|
|
latest_state = next((s for s in latest_states(200) if str(s.get("concern_id") or "") == concern_id), None)
|
|
|
latest_narrative = next((n for n in latest_narratives(200) if str(n.get("concern_id") or "") == concern_id), None)
|
|
|
latest_decision = next((d for d in latest_decisions(200) if str(d.get("concern_id") or "") == concern_id), None)
|
|
|
- latest_regimes = [s for s in recent_regime_samples(500) if str(s.get("concern_id") or "") == concern_id][:24]
|
|
|
+ regime_order = ["1d", "4h", "1h", "15m", "5m", "1m"]
|
|
|
+ latest_regimes_by_timeframe: dict[str, list[dict[str, Any]]] = {tf: [] for tf in regime_order}
|
|
|
+ for sample in recent_regime_samples(2000):
|
|
|
+ if str(sample.get("concern_id") or "") != concern_id:
|
|
|
+ continue
|
|
|
+ timeframe = str(sample.get("timeframe") or "").strip().lower()
|
|
|
+ if not timeframe:
|
|
|
+ continue
|
|
|
+ bucket = latest_regimes_by_timeframe.setdefault(timeframe, [])
|
|
|
+ if len(bucket) >= 24:
|
|
|
+ continue
|
|
|
+ concern_meta = {
|
|
|
+ "account_display": enriched_concern.get("account_display"),
|
|
|
+ "market_display": enriched_concern.get("market_display"),
|
|
|
+ "market_symbol": enriched_concern.get("market_symbol"),
|
|
|
+ }
|
|
|
+ bucket.append({**sample, **concern_meta})
|
|
|
+ latest_regimes = [sample for tf in regime_order for sample in latest_regimes_by_timeframe.get(tf, [])]
|
|
|
|
|
|
return JSONResponse({
|
|
|
"ok": True,
|