revert: Wiederherstellung Codezustand von ca8cee9 (ohne Branch-Historie zu überschreiben)
Reverts cd29c7d..026c51b per git revert. Alle zwischenliegenden Commits bleiben in Gitea sichtbar; der Arbeitsbaum entspricht wieder dem Stand von ca8cee9.
Made-with: Cursor
This commit is contained in:
1 parent
026c51b6b5
commit
06f83e2ffc
10 files changed
+117
-503
No files matched your search
@@ -15,7 +15,6 @@ from typing import Any, Dict, List, Mapping, Optional
|
||||
from models import ActivityEntry
|
||||
|
||||
from csv_parser.module_registry import get_module_definition
|
||||
from data_layer.activity_data_canon import get_activity_module_registry_field_keys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -51,8 +50,10 @@ _ACTIVITY_CSV_REGISTRY_EXCLUDE = frozenset({"date", "start_time", "end_time", "a
|
||||
|
||||
|
||||
def activity_registry_field_keys() -> frozenset[str]:
|
||||
"""Gleiche Menge wie ``ACTIVITY_MODULE_REGISTRY_FIELD_KEYS`` (Phase A: eine Quelle)."""
|
||||
return get_activity_module_registry_field_keys()
|
||||
mod = get_module_definition("activity")
|
||||
if not mod:
|
||||
return frozenset()
|
||||
return frozenset((mod.get("fields") or {}).keys())
|
||||
|
||||
|
||||
def activity_csv_registry_updates_from_mapped(mapped: Mapping[str, Any]) -> Dict[str, Any]:
|
||||
@@ -82,20 +83,11 @@ def activity_csv_registry_updates_from_mapped(mapped: Mapping[str, Any]) -> Dict
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
def _within_num_bounds(v: float | int, spec: dict, *, as_float: bool) -> bool:
|
||||
mn = spec.get("min")
|
||||
mx = spec.get("max")
|
||||
if mn is not None:
|
||||
if as_float and v < float(mn):
|
||||
return False
|
||||
if not as_float and v < int(mn):
|
||||
return False
|
||||
if mx is not None:
|
||||
if as_float and v > float(mx):
|
||||
return False
|
||||
if not as_float and v > int(mx):
|
||||
return False
|
||||
return True
|
||||
def _hr(v: Any) -> float | None:
|
||||
x = _sf(v)
|
||||
if x is None or x < 20 or x > 280:
|
||||
return None
|
||||
return x
|
||||
|
||||
for key, spec in fields.items():
|
||||
if key in _ACTIVITY_CSV_REGISTRY_EXCLUDE:
|
||||
@@ -109,15 +101,11 @@ def activity_csv_registry_updates_from_mapped(mapped: Mapping[str, Any]) -> Dict
|
||||
continue
|
||||
typ = spec.get("type", "string")
|
||||
if typ == "float":
|
||||
v = _sf(raw)
|
||||
if v is not None and not _within_num_bounds(v, spec, as_float=True):
|
||||
v = None
|
||||
v = _hr(raw) if key in ("hr_avg", "hr_max") else _sf(raw)
|
||||
if v is not None:
|
||||
out[key] = v
|
||||
elif typ == "int":
|
||||
v = _si(raw)
|
||||
if v is not None and not _within_num_bounds(v, spec, as_float=False):
|
||||
v = None
|
||||
if v is not None:
|
||||
out[key] = v
|
||||
elif typ == "datetime":
|
||||
@@ -227,7 +215,7 @@ def insert_activity_csv_minimal(
|
||||
training_subcategory: Any,
|
||||
source: str,
|
||||
) -> None:
|
||||
"""INSERT activity_log-Zeile (Universal-CSV): Kernspalten im INSERT; optional zusätzliches PATCH."""
|
||||
"""INSERT minimale activity_log-Zeile (Universal-CSV)."""
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO activity_log (
|
||||
@@ -296,7 +284,7 @@ def run_activity_post_write_hooks_import(
|
||||
kcal_active: Any,
|
||||
kcal_resting: Any,
|
||||
) -> None:
|
||||
"""Auto-Eval nach Import (gleiche Transaktion wie Schreibpfad — keine Abhängigkeit vom DB-Read-Timing)."""
|
||||
"""Auto-Eval nach Import. Kein Spalte→EAV-Sync (siehe run_activity_post_write_hooks)."""
|
||||
if _EVALUATION_AVAILABLE and training_type_id and _evaluate_and_save_activity:
|
||||
try:
|
||||
activity_dict = {
|
||||
|
||||
Reference in new issue
Block a user