Goals -System refactored - Platzhaltersystem enhanced (als draft) #53

Merged
Lars merged 86 commits from develop into main 2026-03-31 11:46:48 +02:00
Showing only changes of commit 43e6c3e7f4 - Show all commits

View File

@ -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:
"""
Calculate total weight for a category
Accepts German or English category names
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)
with get_db() as conn:
@ -117,7 +137,7 @@ def calculate_category_weight(profile_id: str, category: str) -> float:
SELECT key
FROM focus_area_definitions
WHERE category = %s
""", (category,))
""", (category_en,))
focus_areas = [row['key'] for row in cur.fetchall()]