feat: add reference values snapshot endpoints and data layer functions
Deploy Development / deploy (push) Successful in 1m3s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

- Introduced `get_profile_reference_values_current_snapshot` and `get_profile_reference_values_recent_snapshot` functions to retrieve current and recent reference values for profiles.
- Updated the placeholder resolver to include new placeholders for current and recent reference values.
- Added new API endpoints for fetching current and recent reference values snapshots.
- Enhanced the frontend API utility to support the new snapshot endpoints.
- Improved unit tests to validate the new data layer functions and their behavior.
This commit is contained in:
Lars committed 2026-04-19 10:52:31 +02:00
1 parent df0165bee3
commit 42ae796448
7 files changed
+359 -1

No files matched your search

+14
View File
@@ -51,6 +51,10 @@ from data_layer.health_metrics import (
)
from data_layer.prompt_output_compact import compact_json_payload_for_prompts
from data_layer.reference_values import (
get_profile_reference_values_current_snapshot,
get_profile_reference_values_recent_snapshot,
)
from placeholder_registry import build_ai_placeholder_caption, get_registry
@@ -810,6 +814,8 @@ _SAFE_JSON_NONE_REASON: Dict[str, str] = {
"active_goals_json": "Aktive Ziele als JSON nicht ermittelbar",
"focus_areas_weighted_json": "Gewichtete Fokusbereiche JSON nicht ermittelbar",
"focus_area_weights_json": "Fokus-Gewichtungen JSON nicht ermittelbar",
"reference_values_current_json": "Referenzwerte (aktuell) nicht ermittelbar",
"reference_values_recent_json": "Referenzwerte (Verlauf) nicht ermittelbar",
}
@@ -1025,6 +1031,8 @@ def _safe_json(func_name: str, profile_id: str) -> str:
'active_goals_json': lambda pid: _get_active_goals_json(pid),
'focus_areas_weighted_json': lambda pid: _get_focus_areas_weighted_json(pid),
'focus_area_weights_json': lambda pid: json.dumps(scores.get_user_focus_weights(pid), ensure_ascii=False),
'reference_values_current_json': get_profile_reference_values_current_snapshot,
'reference_values_recent_json': get_profile_reference_values_recent_snapshot,
}
func = func_map.get(func_name)
@@ -1674,6 +1682,8 @@ PLACEHOLDER_MAP: Dict[str, Callable[[str], str]] = {
'{{focus_areas_weighted_json}}': lambda pid: _safe_json('focus_areas_weighted_json', pid),
'{{focus_areas_weighted_md}}': lambda pid: _safe_str('focus_areas_weighted_md', pid),
'{{focus_area_weights_json}}': lambda pid: _safe_json('focus_area_weights_json', pid),
'{{reference_values_current_json}}': lambda pid: _safe_json('reference_values_current_json', pid),
'{{reference_values_recent_json}}': lambda pid: _safe_json('reference_values_recent_json', pid),
'{{top_3_focus_areas}}': lambda pid: _safe_str('top_3_focus_areas', pid),
'{{top_3_goals_behind_schedule}}': lambda pid: _safe_str('top_3_goals_behind_schedule', pid),
'{{top_3_goals_on_track}}': lambda pid: _safe_str('top_3_goals_on_track', pid),
@@ -1823,6 +1833,10 @@ def get_available_placeholders(categories: Optional[List[str]] = None) -> Dict[s
'zeitraum': [
'{{datum_heute}}', '{{zeitraum_7d}}', '{{zeitraum_30d}}', '{{zeitraum_90d}}'
],
'referenzwerte': [
'{{reference_values_current_json}}',
'{{reference_values_recent_json}}',
],
'phase0b_meta': [
'{{goal_progress_score}}', '{{data_quality_score}}',
],