feat: Add new profile and time period placeholders in placeholder_resolver.py
Deploy Development / deploy (push) Successful in 50s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 16s

- Introduced functions to retrieve profile name, age, height, and gender for better placeholder resolution.
- Added functions for displaying current date and time period labels (last 7, 30, and 90 days).
- Updated PLACEHOLDER_MAP to utilize new functions for improved readability and maintainability.
- Enhanced placeholder registrations in __init__.py to include new modules for sleep, vital metrics, and profile time periods.

These changes enhance the flexibility and functionality of the placeholder system, allowing for more dynamic content generation.
This commit is contained in:
Lars committed 2026-04-11 21:08:34 +02:00
1 parent e9e094c6a4
commit 2ea5f905c4
9 files changed
+1233 -68

No files matched your search

@@ -0,0 +1,96 @@
"""Registry: Korrelations- und Treiber-Metriken (Data Layer correlations)."""
from placeholder_registry import (
PlaceholderMetadata,
MissingValuePolicy,
OutputType,
PlaceholderType,
register_placeholder,
)
from ._evidence import tag_standard_evidence
CAT = "Korrelationen"
MVP = lambda reason, disp: MissingValuePolicy(
available=False, value_raw=None, missing_reason=reason, legacy_display=disp
)
def register_korrelationen():
for key, dl_fn, desc, tables, sem in [
(
"correlation_energy_weight_lag",
"calculate_lag_correlation",
"JSON: Lag-Korrelation Energiebilanz ↔ Gewicht",
["nutrition_log", "weight_log"],
"correlations.calculate_lag_correlation(pid, 'energy', 'weight')",
),
(
"correlation_protein_lbm",
"calculate_lag_correlation",
"JSON: Lag-Korrelation Protein ↔ Magermasse",
["nutrition_log", "weight_log", "caliper_log"],
"correlations.calculate_lag_correlation(pid, 'protein', 'lbm')",
),
(
"correlation_load_hrv",
"calculate_lag_correlation",
"JSON: Lag-Korrelation Trainingslast ↔ HRV",
["activity_log", "vitals_baseline"],
"correlations.calculate_lag_correlation(pid, 'training_load', 'hrv')",
),
(
"correlation_load_rhr",
"calculate_lag_correlation",
"JSON: Lag-Korrelation Trainingslast ↔ Ruhepuls",
["activity_log", "vitals_baseline"],
"correlations.calculate_lag_correlation(pid, 'training_load', 'rhr')",
),
(
"plateau_detected",
"calculate_plateau_detected",
"JSON: Platten-Erkennung (Gewicht/Körper)",
["weight_log", "caliper_log"],
"correlations.calculate_plateau_detected",
),
(
"top_drivers",
"calculate_top_drivers",
"JSON: Top Treiber für Ziel-/Score-Variablen",
["weight_log", "nutrition_log", "activity_log", "vitals_baseline", "sleep_log"],
"correlations.calculate_top_drivers",
),
]:
m = PlaceholderMetadata(
key=key,
category=CAT,
description=desc,
resolver_module="backend/placeholder_resolver.py",
resolver_function="_safe_json",
data_layer_module="backend/data_layer/correlations.py",
data_layer_function=dl_fn,
source_tables=tables,
semantic_contract=sem,
business_meaning="Strukturierte Korrelationsausgabe für KI",
unit="JSON",
time_window="funktionsintern",
output_type=OutputType.JSON,
placeholder_type=PlaceholderType.RAW_DATA,
format_hint="JSON-String",
example_output="{}",
minimum_data_requirements="Ausreichend gekoppelte Zeitreihen",
quality_filter_policy=None,
confidence_logic="Wie correlations.*",
missing_value_policy=MVP("insufficient_data", "{}"),
known_limitations="Bei wenigen Daten leer oder wenig robust",
layer_1_decision=f"correlations.{dl_fn}",
layer_2a_decision="_safe_json",
layer_2b_reuse_possible=True,
architecture_alignment="Phase 0c",
issue_53_alignment="Layer 1",
evidence={},
)
tag_standard_evidence(m)
register_placeholder(m)
register_korrelationen()