From 38d033f6a947a493b6314357695b30becdb21e9a Mon Sep 17 00:00:00 2001 From: Tudor Sitaru Date: Tue, 19 May 2026 09:31:15 +0100 Subject: [PATCH] fix(rankings): expose selected metric under stable `value` key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The /api/rankings endpoint returned each row keyed by the metric's column name (e.g. rwm_high_pct) but never under a generic `value` field. The frontend RankingItem type and RankingsView both read ranking.value, so every row rendered "—" for every metric — the default rwm_expected_pct included. Add `df["value"] = df[metric]` before JSON serialisation so the frontend gets the value it has always expected. The raw metric column is still in the row for any caller that wants it explicitly. Co-Authored-By: Claude Opus 4.7 --- backend/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/app.py b/backend/app.py index 49d368b..f4da070 100644 --- a/backend/app.py +++ b/backend/app.py @@ -818,7 +818,12 @@ async def get_rankings( # Return only relevant fields for rankings available_cols = [c for c in RANKING_COLUMNS if c in df.columns] - df = df[available_cols] + df = df[available_cols].copy() + + # Surface the requested metric under a stable `value` key so the + # frontend doesn't need to know each metric's column name. The raw + # metric column is also kept in the row for callers that want it. + df["value"] = df[metric] return { "metric": metric,