fix: Phase 0b - map German to English category names
This commit is contained in:
parent
e3e635d9f5
commit
43e6c3e7f4
|
|
@ -104,11 +104,31 @@ def map_focus_to_score_components() -> Dict[str, str]:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def map_category_de_to_en(category_de: str) -> str:
|
||||||
|
"""
|
||||||
|
Map German category names to English database names
|
||||||
|
"""
|
||||||
|
mapping = {
|
||||||
|
'körper': 'body_composition',
|
||||||
|
'ernährung': 'nutrition', # Note: no nutrition category in DB, returns empty
|
||||||
|
'aktivität': 'training',
|
||||||
|
'recovery': 'recovery',
|
||||||
|
'vitalwerte': 'health',
|
||||||
|
'mental': 'mental',
|
||||||
|
'lebensstil': 'health', # Maps to general health
|
||||||
|
}
|
||||||
|
return mapping.get(category_de, category_de)
|
||||||
|
|
||||||
|
|
||||||
def calculate_category_weight(profile_id: str, category: str) -> float:
|
def calculate_category_weight(profile_id: str, category: str) -> float:
|
||||||
"""
|
"""
|
||||||
Calculate total weight for a category
|
Calculate total weight for a category
|
||||||
|
Accepts German or English category names
|
||||||
Returns sum of all focus area weights in this category
|
Returns sum of all focus area weights in this category
|
||||||
"""
|
"""
|
||||||
|
# Map German to English if needed
|
||||||
|
category_en = map_category_de_to_en(category)
|
||||||
|
|
||||||
focus_weights = get_user_focus_weights(profile_id)
|
focus_weights = get_user_focus_weights(profile_id)
|
||||||
|
|
||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
|
|
@ -117,7 +137,7 @@ def calculate_category_weight(profile_id: str, category: str) -> float:
|
||||||
SELECT key
|
SELECT key
|
||||||
FROM focus_area_definitions
|
FROM focus_area_definitions
|
||||||
WHERE category = %s
|
WHERE category = %s
|
||||||
""", (category,))
|
""", (category_en,))
|
||||||
|
|
||||||
focus_areas = [row['key'] for row in cur.fetchall()]
|
focus_areas = [row['key'] for row in cur.fetchall()]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user