feat: Update Gitea issues index and enhance data layer metrics
- Updated the Gitea issues index to reflect the latest state as of 2026-04-11, adding issue #76 to the list. - Refined data handling in `activity_metrics.py`, `body_metrics.py`, `nutrition_metrics.py`, and `scores.py` to ensure consistent float conversions for calculations, improving accuracy in metric evaluations. - Enhanced the calculation logic for various metrics to handle potential None values more robustly, ensuring smoother data processing and improved reliability across the application. These changes improve the clarity of the Gitea issues documentation and enhance the overall accuracy and reliability of health and fitness metrics.
This commit is contained in:
1 parent
4868e44882
commit
d7cefdd9e9
7 files changed
+121
-50
No files matched your search
@@ -224,8 +224,8 @@ def calculate_goal_progress_score(profile_id: str) -> Optional[int]:
|
||||
if total_weight == 0:
|
||||
return None
|
||||
|
||||
# Normalize to 0-100
|
||||
final_score = total_score / total_weight
|
||||
# Normalize to 0-100 (Explizit float: Zwischensummen können Decimal aus DB sein)
|
||||
final_score = float(total_score) / float(total_weight)
|
||||
|
||||
return int(final_score)
|
||||
|
||||
@@ -533,11 +533,19 @@ def calculate_focus_area_progress(profile_id: str, focus_area_id: str) -> Option
|
||||
if not goals:
|
||||
return None
|
||||
|
||||
# Weighted average by contribution_weight (Numeric → float)
|
||||
total_progress = sum(
|
||||
float(g['progress_pct']) * float(g['contribution_weight']) for g in goals
|
||||
)
|
||||
total_weight = sum(float(g['contribution_weight']) for g in goals)
|
||||
# Weighted average; progress_pct darf NULL sein (Ziele ohne quantitative Berechnung)
|
||||
parts: List[tuple] = []
|
||||
for g in goals:
|
||||
pct = g['progress_pct']
|
||||
if pct is None:
|
||||
continue
|
||||
parts.append((float(pct), float(g['contribution_weight'])))
|
||||
|
||||
if not parts:
|
||||
return None
|
||||
|
||||
total_progress = sum(p * w for p, w in parts)
|
||||
total_weight = sum(w for _, w in parts)
|
||||
|
||||
return int(total_progress / total_weight) if total_weight > 0 else None
|
||||
|
||||
|
||||
Reference in new issue
Block a user