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 6f94154b9e - Show all commits

View File

@ -477,6 +477,7 @@ def _safe_int(func_name: str, profile_id: str) -> str:
Returns: Returns:
String representation of integer value or 'nicht verfügbar' String representation of integer value or 'nicht verfügbar'
""" """
import traceback
try: try:
# Import calculations dynamically to avoid circular imports # Import calculations dynamically to avoid circular imports
from calculations import scores, body_metrics, nutrition_metrics, activity_metrics, recovery_metrics, correlation_metrics from calculations import scores, body_metrics, nutrition_metrics, activity_metrics, recovery_metrics, correlation_metrics
@ -522,6 +523,8 @@ def _safe_int(func_name: str, profile_id: str) -> str:
result = func(profile_id) result = func(profile_id)
return str(int(result)) if result is not None else 'nicht verfügbar' return str(int(result)) if result is not None else 'nicht verfügbar'
except Exception as e: except Exception as e:
print(f"[ERROR] _safe_int({func_name}, {profile_id}): {type(e).__name__}: {e}")
traceback.print_exc()
return 'nicht verfügbar' return 'nicht verfügbar'
@ -537,6 +540,7 @@ def _safe_float(func_name: str, profile_id: str, decimals: int = 1) -> str:
Returns: Returns:
String representation of float value or 'nicht verfügbar' String representation of float value or 'nicht verfügbar'
""" """
import traceback
try: try:
from calculations import body_metrics, nutrition_metrics, activity_metrics, recovery_metrics, scores from calculations import body_metrics, nutrition_metrics, activity_metrics, recovery_metrics, scores
@ -577,6 +581,8 @@ def _safe_float(func_name: str, profile_id: str, decimals: int = 1) -> str:
result = func(profile_id) result = func(profile_id)
return f"{result:.{decimals}f}" if result is not None else 'nicht verfügbar' return f"{result:.{decimals}f}" if result is not None else 'nicht verfügbar'
except Exception as e: except Exception as e:
print(f"[ERROR] _safe_float({func_name}, {profile_id}): {type(e).__name__}: {e}")
traceback.print_exc()
return 'nicht verfügbar' return 'nicht verfügbar'
@ -584,6 +590,7 @@ def _safe_str(func_name: str, profile_id: str) -> str:
""" """
Safely call calculation function and return string value or fallback. Safely call calculation function and return string value or fallback.
""" """
import traceback
try: try:
from calculations import body_metrics, nutrition_metrics, activity_metrics, scores, correlation_metrics from calculations import body_metrics, nutrition_metrics, activity_metrics, scores, correlation_metrics
@ -609,6 +616,8 @@ def _safe_str(func_name: str, profile_id: str) -> str:
result = func(profile_id) result = func(profile_id)
return str(result) if result is not None else 'nicht verfügbar' return str(result) if result is not None else 'nicht verfügbar'
except Exception as e: except Exception as e:
print(f"[ERROR] _safe_str({func_name}, {profile_id}): {type(e).__name__}: {e}")
traceback.print_exc()
return 'nicht verfügbar' return 'nicht verfügbar'
@ -616,6 +625,7 @@ def _safe_json(func_name: str, profile_id: str) -> str:
""" """
Safely call calculation function and return JSON string or fallback. Safely call calculation function and return JSON string or fallback.
""" """
import traceback
try: try:
import json import json
from calculations import scores, correlation_metrics from calculations import scores, correlation_metrics
@ -647,6 +657,8 @@ def _safe_json(func_name: str, profile_id: str) -> str:
else: else:
return json.dumps(result, ensure_ascii=False) return json.dumps(result, ensure_ascii=False)
except Exception as e: except Exception as e:
print(f"[ERROR] _safe_json({func_name}, {profile_id}): {type(e).__name__}: {e}")
traceback.print_exc()
return '{}' return '{}'