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 14c4ea13d9 - Show all commits

View File

@ -407,6 +407,21 @@ def _fetch_by_aggregation_method(
row = cur.fetchone()
return float(row['max_value']) if row and row['max_value'] is not None else None
elif method == 'avg_per_week_30d':
# Average count per week over 30 days
# Use case: Training frequency per week (smoothed over 4.3 weeks)
days_ago = date.today() - timedelta(days=30)
params = [profile_id, days_ago] + filter_params
cur.execute(f"""
SELECT COUNT(*) as count_value FROM {table}
WHERE profile_id = %s AND {date_col} >= %s{filter_sql}
""", params)
row = cur.fetchone()
if row and row['count_value'] is not None:
# 30 days = 4.285 weeks (30/7)
return round(float(row['count_value']) / 4.285, 2)
return None
else:
print(f"[WARNING] Unknown aggregation method: {method}")
return None