Goals -System refactored - Platzhaltersystem enhanced (als draft) #53
|
|
@ -400,6 +400,10 @@ def _score_weight_trend(profile_id: str) -> Optional[int]:
|
||||||
if None in [current, target]:
|
if None in [current, target]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Convert Decimal to float (PostgreSQL NUMERIC returns Decimal)
|
||||||
|
current = float(current)
|
||||||
|
target = float(target)
|
||||||
|
|
||||||
# If no start_value, use oldest weight in last 90 days
|
# If no start_value, use oldest weight in last 90 days
|
||||||
if start is None:
|
if start is None:
|
||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
|
|
@ -414,6 +418,8 @@ def _score_weight_trend(profile_id: str) -> Optional[int]:
|
||||||
""", (profile_id,))
|
""", (profile_id,))
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
start = float(row['weight']) if row else current
|
start = float(row['weight']) if row else current
|
||||||
|
else:
|
||||||
|
start = float(start)
|
||||||
|
|
||||||
# Progress percentage
|
# Progress percentage
|
||||||
progress_pct = calculate_goal_progress_pct(current, target, start)
|
progress_pct = calculate_goal_progress_pct(current, target, start)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user