Goals -System refactored - Platzhaltersystem enhanced (als draft) #53
|
|
@ -41,7 +41,7 @@ def calculate_energy_balance_7d(profile_id: str) -> Optional[float]:
|
|||
if len(calories) < 4: # Need at least 4 days
|
||||
return None
|
||||
|
||||
avg_intake = sum(calories) / len(calories)
|
||||
avg_intake = float(sum(calories) / len(calories))
|
||||
|
||||
# Get estimated TDEE (simplified - could use Harris-Benedict)
|
||||
# For now, use weight-based estimate
|
||||
|
|
@ -123,7 +123,7 @@ def calculate_protein_g_per_kg(profile_id: str) -> Optional[float]:
|
|||
if len(protein_values) < 4:
|
||||
return None
|
||||
|
||||
avg_protein = sum(protein_values) / len(protein_values)
|
||||
avg_protein = float(sum(protein_values) / len(protein_values))
|
||||
protein_per_kg = avg_protein / weight
|
||||
|
||||
return round(protein_per_kg, 2)
|
||||
|
|
@ -172,7 +172,7 @@ def calculate_protein_days_in_target(profile_id: str, target_low: float = 1.6, t
|
|||
total_days = len(protein_data)
|
||||
|
||||
for row in protein_data:
|
||||
protein_per_kg = row['protein_g'] / weight
|
||||
protein_per_kg = float(row['protein_g']) / weight
|
||||
if target_low <= protein_per_kg <= target_high:
|
||||
days_in_target += 1
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ def calculate_protein_adequacy_28d(profile_id: str) -> Optional[int]:
|
|||
AND protein_g IS NOT NULL
|
||||
""", (profile_id,))
|
||||
|
||||
protein_values = [row['protein_g'] for row in cur.fetchall()]
|
||||
protein_values = [float(row['protein_g']) for row in cur.fetchall()]
|
||||
|
||||
if len(protein_values) < 18: # 60% coverage
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user