From dfaf24d74cc4715998db09de570cb5a6d5ba34d9 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 26 Mar 2026 09:10:55 +0100 Subject: [PATCH] fix: correct SQL column names in placeholder_resolver - caliper_summary: use body_fat_pct (not bf_jpl) - circ_summary: use c_chest, c_waist, c_hip (not brust, taille, huefte) - get_latest_bf: use body_fat_pct for consistency Fixes SQL errors when running base prompts that feed pipeline prompts. Co-Authored-By: Claude Opus 4.6 --- backend/placeholder_resolver.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/placeholder_resolver.py b/backend/placeholder_resolver.py index aafec51..34072a0 100644 --- a/backend/placeholder_resolver.py +++ b/backend/placeholder_resolver.py @@ -65,13 +65,13 @@ def get_latest_bf(profile_id: str) -> Optional[str]: with get_db() as conn: cur = get_cursor(conn) cur.execute( - """SELECT bf_jpl FROM caliper_log - WHERE profile_id=%s AND bf_jpl IS NOT NULL + """SELECT body_fat_pct FROM caliper_log + WHERE profile_id=%s AND body_fat_pct IS NOT NULL ORDER BY date DESC LIMIT 1""", (profile_id,) ) row = cur.fetchone() - return f"{row['bf_jpl']:.1f}%" if row else "nicht verfügbar" + return f"{row['body_fat_pct']:.1f}%" if row else "nicht verfügbar" def get_nutrition_avg(profile_id: str, field: str, days: int = 30) -> str: @@ -108,8 +108,8 @@ def get_caliper_summary(profile_id: str) -> str: with get_db() as conn: cur = get_cursor(conn) cur.execute( - """SELECT bf_jpl, bf_katch, date FROM caliper_log - WHERE profile_id=%s AND bf_jpl IS NOT NULL + """SELECT body_fat_pct, sf_method, date FROM caliper_log + WHERE profile_id=%s AND body_fat_pct IS NOT NULL ORDER BY date DESC LIMIT 1""", (profile_id,) ) @@ -118,7 +118,8 @@ def get_caliper_summary(profile_id: str) -> str: if not row: return "keine Caliper-Messungen" - return f"JPL: {row['bf_jpl']:.1f}% (Katch: {row['bf_katch']:.1f}% am {row['date']})" + method = row.get('sf_method', 'unbekannt') + return f"{row['body_fat_pct']:.1f}% ({method} am {row['date']})" def get_circ_summary(profile_id: str) -> str: @@ -126,7 +127,7 @@ def get_circ_summary(profile_id: str) -> str: with get_db() as conn: cur = get_cursor(conn) cur.execute( - """SELECT brust, taille, huefte, date FROM circumference_log + """SELECT c_chest, c_waist, c_hip, date FROM circumference_log WHERE profile_id=%s ORDER BY date DESC LIMIT 1""", (profile_id,) @@ -137,9 +138,9 @@ def get_circ_summary(profile_id: str) -> str: return "keine Umfangsmessungen" parts = [] - if row.get('brust'): parts.append(f"Brust {row['brust']}cm") - if row.get('taille'): parts.append(f"Taille {row['taille']}cm") - if row.get('huefte'): parts.append(f"Hüfte {row['huefte']}cm") + if row.get('c_chest'): parts.append(f"Brust {row['c_chest']:.1f}cm") + if row.get('c_waist'): parts.append(f"Taille {row['c_waist']:.1f}cm") + if row.get('c_hip'): parts.append(f"Hüfte {row['c_hip']:.1f}cm") return f"{', '.join(parts)} ({row['date']})" if parts else "keine Daten"