- Migrated all 20 calculation functions from calculations/body_metrics.py to data_layer/body_metrics.py - Functions: weight trends (7d median, 28d/90d slopes, goal projection, progress) - Functions: body composition (FM/LBM changes) - Functions: circumferences (waist/hip/chest/arm/thigh deltas, WHR) - Functions: recomposition quadrant - Functions: scoring (body progress, data quality) - Updated data_layer/__init__.py with 20 new exports - Refactored placeholder_resolver.py to import body_metrics from data_layer Module 1/6 complete. Single Source of Truth for body metrics established. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
94 lines
2.6 KiB
Python
94 lines
2.6 KiB
Python
"""
|
|
Data Layer - Pure Data Retrieval & Calculation Logic
|
|
|
|
This module provides structured data functions for all metrics.
|
|
NO FORMATTING. NO STRINGS WITH UNITS. Only structured data.
|
|
|
|
Usage:
|
|
from data_layer.body_metrics import get_weight_trend_data
|
|
|
|
data = get_weight_trend_data(profile_id="123", days=28)
|
|
# Returns: {"slope_28d": 0.23, "confidence": "high", ...}
|
|
|
|
Modules:
|
|
- body_metrics: Weight, body fat, lean mass, circumferences
|
|
- nutrition_metrics: Calories, protein, macros, adherence
|
|
- activity_metrics: Training volume, quality, abilities
|
|
- recovery_metrics: Sleep, RHR, HRV, recovery score
|
|
- health_metrics: Blood pressure, VO2Max, health stability
|
|
- goals: Active goals, progress, projections
|
|
- correlations: Lag-analysis, plateau detection
|
|
- utils: Shared functions (confidence, baseline, outliers)
|
|
|
|
Phase 0c: Multi-Layer Architecture
|
|
Version: 1.0
|
|
Created: 2026-03-28
|
|
"""
|
|
|
|
# Core utilities
|
|
from .utils import *
|
|
|
|
# Metric modules
|
|
from .body_metrics import *
|
|
from .nutrition_metrics import *
|
|
from .activity_metrics import *
|
|
from .recovery_metrics import *
|
|
from .health_metrics import *
|
|
|
|
# Future imports (will be added as modules are created):
|
|
# from .goals import *
|
|
# from .correlations import *
|
|
|
|
__all__ = [
|
|
# Utils
|
|
'calculate_confidence',
|
|
'serialize_dates',
|
|
|
|
# Body Metrics (Basic)
|
|
'get_latest_weight_data',
|
|
'get_weight_trend_data',
|
|
'get_body_composition_data',
|
|
'get_circumference_summary_data',
|
|
|
|
# Body Metrics (Calculated)
|
|
'calculate_weight_7d_median',
|
|
'calculate_weight_28d_slope',
|
|
'calculate_weight_90d_slope',
|
|
'calculate_goal_projection_date',
|
|
'calculate_goal_progress_pct',
|
|
'calculate_fm_28d_change',
|
|
'calculate_lbm_28d_change',
|
|
'calculate_waist_28d_delta',
|
|
'calculate_hip_28d_delta',
|
|
'calculate_chest_28d_delta',
|
|
'calculate_arm_28d_delta',
|
|
'calculate_thigh_28d_delta',
|
|
'calculate_waist_hip_ratio',
|
|
'calculate_recomposition_quadrant',
|
|
'calculate_body_progress_score',
|
|
'calculate_body_data_quality',
|
|
|
|
# Nutrition Metrics
|
|
'get_nutrition_average_data',
|
|
'get_nutrition_days_data',
|
|
'get_protein_targets_data',
|
|
'get_energy_balance_data',
|
|
'get_protein_adequacy_data',
|
|
'get_macro_consistency_data',
|
|
|
|
# Activity Metrics
|
|
'get_activity_summary_data',
|
|
'get_activity_detail_data',
|
|
'get_training_type_distribution_data',
|
|
|
|
# Recovery Metrics
|
|
'get_sleep_duration_data',
|
|
'get_sleep_quality_data',
|
|
'get_rest_days_data',
|
|
|
|
# Health Metrics
|
|
'get_resting_heart_rate_data',
|
|
'get_heart_rate_variability_data',
|
|
'get_vo2_max_data',
|
|
]
|