Goals -System refactored - Platzhaltersystem enhanced (als draft) #53
|
|
@ -477,6 +477,7 @@ def _safe_int(func_name: str, profile_id: str) -> str:
|
|||
Returns:
|
||||
String representation of integer value or 'nicht verfügbar'
|
||||
"""
|
||||
import traceback
|
||||
try:
|
||||
# Import calculations dynamically to avoid circular imports
|
||||
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)
|
||||
return str(int(result)) if result is not None else 'nicht verfügbar'
|
||||
except Exception as e:
|
||||
print(f"[ERROR] _safe_int({func_name}, {profile_id}): {type(e).__name__}: {e}")
|
||||
traceback.print_exc()
|
||||
return 'nicht verfügbar'
|
||||
|
||||
|
||||
|
|
@ -537,6 +540,7 @@ def _safe_float(func_name: str, profile_id: str, decimals: int = 1) -> str:
|
|||
Returns:
|
||||
String representation of float value or 'nicht verfügbar'
|
||||
"""
|
||||
import traceback
|
||||
try:
|
||||
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)
|
||||
return f"{result:.{decimals}f}" if result is not None else 'nicht verfügbar'
|
||||
except Exception as e:
|
||||
print(f"[ERROR] _safe_float({func_name}, {profile_id}): {type(e).__name__}: {e}")
|
||||
traceback.print_exc()
|
||||
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.
|
||||
"""
|
||||
import traceback
|
||||
try:
|
||||
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)
|
||||
return str(result) if result is not None else 'nicht verfügbar'
|
||||
except Exception as e:
|
||||
print(f"[ERROR] _safe_str({func_name}, {profile_id}): {type(e).__name__}: {e}")
|
||||
traceback.print_exc()
|
||||
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.
|
||||
"""
|
||||
import traceback
|
||||
try:
|
||||
import json
|
||||
from calculations import scores, correlation_metrics
|
||||
|
|
@ -647,6 +657,8 @@ def _safe_json(func_name: str, profile_id: str) -> str:
|
|||
else:
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
except Exception as e:
|
||||
print(f"[ERROR] _safe_json({func_name}, {profile_id}): {type(e).__name__}: {e}")
|
||||
traceback.print_exc()
|
||||
return '{}'
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user