feat: Phase 0c - migrate correlation_metrics to data_layer/correlations (11 functions)
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 12s

- Created NEW data_layer/correlations.py with all 11 correlation functions
- Functions: Lag correlation (main + 3 helpers: energy/weight, protein/LBM, load/vitals)
- Functions: Sleep-recovery correlation
- Functions: Plateau detection (main + 3 detectors: weight, strength, endurance)
- Functions: Top drivers analysis
- Functions: Correlation confidence helper
- Updated data_layer/__init__.py to import correlations module and export 5 main functions
- Refactored placeholder_resolver.py to import correlations from data_layer (as correlation_metrics alias)
- Removed ALL imports from calculations/ module in placeholder_resolver.py

Module 6/6 complete. ALL calculations migrated to data_layer!
Phase 0c Multi-Layer Architecture COMPLETE.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 4.6 committed 2026-03-28 20:28:26 +01:00
1 parent dba6814bc2
commit befa060671
3 files changed
+516 -4

No files matched your search

+5 -3
View File
@@ -417,8 +417,8 @@ def _safe_int(func_name: str, profile_id: str) -> str:
import traceback
try:
# Import calculations dynamically to avoid circular imports
from calculations import correlation_metrics
from data_layer import body_metrics, nutrition_metrics, activity_metrics, recovery_metrics, scores
from data_layer import correlations as correlation_metrics
# Map function names to actual functions
func_map = {
@@ -530,7 +530,8 @@ def _safe_str(func_name: str, profile_id: str) -> str:
"""
import traceback
try:
from calculations import body_metrics, nutrition_metrics, activity_metrics, scores, correlation_metrics
from data_layer import body_metrics, nutrition_metrics, activity_metrics, scores
from data_layer import correlations as correlation_metrics
func_map = {
'top_goal_name': lambda pid: (scores.get_top_priority_goal(pid).get('name') or scores.get_top_priority_goal(pid).get('goal_type')) if scores.get_top_priority_goal(pid) else None,
@@ -566,7 +567,8 @@ def _safe_json(func_name: str, profile_id: str) -> str:
import traceback
try:
import json
from calculations import scores, correlation_metrics
from data_layer import scores
from data_layer import correlations as correlation_metrics
func_map = {
'correlation_energy_weight_lag': lambda pid: correlation_metrics.calculate_lag_correlation(pid, 'energy', 'weight'),