fix: Phase 0b - PostgreSQL Decimal type handling
TypeError: unsupported operand type(s) for *: 'decimal.Decimal' and 'float' TypeError: unsupported operand type(s) for -: 'float' and 'decimal.Decimal' PostgreSQL NUMERIC/DECIMAL columns return decimal.Decimal objects, not float. These cannot be mixed in arithmetic operations. Fixed 3 locations: - Line 62: float(weight_row['weight']) * 32.5 - Line 153: float(weight_row['weight']) for protein_per_kg - Line 202: float(weight_row['avg_weight']) for adequacy calc Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6f20915d73
commit
78437b649f
|
|
@ -59,7 +59,7 @@ def calculate_energy_balance_7d(profile_id: str) -> Optional[float]:
|
|||
|
||||
# Simple TDEE estimate: bodyweight (kg) × 30-35
|
||||
# TODO: Improve with activity level, age, gender
|
||||
estimated_tdee = weight_row['weight'] * 32.5
|
||||
estimated_tdee = float(weight_row['weight']) * 32.5
|
||||
|
||||
balance = avg_intake - estimated_tdee
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ def calculate_protein_g_per_kg(profile_id: str) -> Optional[float]:
|
|||
if not weight_row:
|
||||
return None
|
||||
|
||||
weight = weight_row['weight']
|
||||
weight = float(weight_row['weight'])
|
||||
|
||||
# Get protein intake
|
||||
cur.execute("""
|
||||
|
|
@ -150,7 +150,7 @@ def calculate_protein_days_in_target(profile_id: str, target_low: float = 1.6, t
|
|||
if not weight_row:
|
||||
return None
|
||||
|
||||
weight = weight_row['weight']
|
||||
weight = float(weight_row['weight'])
|
||||
|
||||
# Get protein intake last 7 days
|
||||
cur.execute("""
|
||||
|
|
@ -199,7 +199,7 @@ def calculate_protein_adequacy_28d(profile_id: str) -> Optional[int]:
|
|||
if not weight_row or not weight_row['avg_weight']:
|
||||
return None
|
||||
|
||||
weight = weight_row['avg_weight']
|
||||
weight = float(weight_row['avg_weight'])
|
||||
|
||||
# Get protein intake (28d)
|
||||
cur.execute("""
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user