feat: Add Activity Session Metrics functionality
- Introduced Activity Session Metrics for enhanced tracking of session data. - Updated backend to support new API endpoints for managing session metrics. - Added new Pydantic models for activity metrics and replaced metrics functionality. - Enhanced data layer to include session metrics in recent training session data. - Updated documentation to reflect changes in session metrics handling.
This commit is contained in:
1 parent
1b01f5e6d0
commit
48508c164e
13 files changed
+1257
-7
No files matched your search
@@ -22,6 +22,7 @@ from typing import Dict, List, Optional, Any
|
||||
from datetime import datetime, timedelta, date, time
|
||||
import statistics
|
||||
from db import get_db, get_cursor, r2d
|
||||
from data_layer.activity_session_metrics import enrich_sessions_with_metrics
|
||||
from data_layer.utils import calculate_confidence, safe_float, safe_int, serialize_dates
|
||||
|
||||
|
||||
@@ -1112,6 +1113,7 @@ def get_training_sessions_recent_weeks_data(
|
||||
(profile_id, cutoff),
|
||||
)
|
||||
rows = [r2d(r) for r in cur.fetchall()]
|
||||
enrich_sessions_with_metrics(cur, rows)
|
||||
|
||||
if not rows:
|
||||
return {
|
||||
@@ -1141,6 +1143,7 @@ def get_training_sessions_recent_weeks_data(
|
||||
hr_m = r.get("hr_max")
|
||||
by_week[wk].append(
|
||||
{
|
||||
"id": str(r["id"]),
|
||||
"date": d,
|
||||
"start_time": str(r["start_time"]) if r.get("start_time") is not None else None,
|
||||
"activity_type": r.get("activity_type"),
|
||||
@@ -1151,6 +1154,7 @@ def get_training_sessions_recent_weeks_data(
|
||||
"hr_avg": int(hr_a) if hr_a is not None else None,
|
||||
"hr_max": int(hr_m) if hr_m is not None else None,
|
||||
"rpe": int(r["rpe"]) if r.get("rpe") is not None else None,
|
||||
"session_metrics": r.get("session_metrics", []),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user