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
@@ -763,6 +763,23 @@ def _import_vitals_baseline(
|
||||
}
|
||||
|
||||
|
||||
def _sf_act(val: Any) -> float | None:
|
||||
try:
|
||||
return round(float(val), 1) if val is not None else None
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def _activity_hr_bpm(val: Any) -> float | None:
|
||||
"""Plausible Herzfrequenz (Import); größere Werte oft Fehlzuordnung (z. B. Schrittzahl) → NUMERIC-Overflow."""
|
||||
v = _sf_act(val)
|
||||
if v is None:
|
||||
return None
|
||||
if v < 20 or v > 280:
|
||||
return None
|
||||
return v
|
||||
|
||||
|
||||
def _looks_like_time_only(s: str) -> bool:
|
||||
t = s.strip()
|
||||
if not t or " " in t:
|
||||
@@ -798,10 +815,7 @@ def _import_activity(
|
||||
run_activity_post_write_hooks_import,
|
||||
update_activity_columns,
|
||||
)
|
||||
from data_layer.activity_session_metrics import (
|
||||
apply_activity_mapped_column_aliases,
|
||||
upsert_session_metrics_from_csv_mapped,
|
||||
)
|
||||
from data_layer.activity_session_metrics import upsert_session_metrics_from_csv_mapped
|
||||
|
||||
rows_total = 0
|
||||
inserted = 0
|
||||
@@ -859,6 +873,19 @@ def _import_activity(
|
||||
else:
|
||||
end_str = ""
|
||||
|
||||
duration_min = mapped.get("duration_min")
|
||||
if duration_min is not None:
|
||||
try:
|
||||
duration_min = round(float(duration_min), 1)
|
||||
except (TypeError, ValueError):
|
||||
duration_min = None
|
||||
|
||||
kcal_a = _sf_act(mapped.get("kcal_active"))
|
||||
kcal_r = _sf_act(mapped.get("kcal_resting"))
|
||||
hr_a = _activity_hr_bpm(mapped.get("hr_avg"))
|
||||
hr_m = _activity_hr_bpm(mapped.get("hr_max"))
|
||||
dist = _sf_act(mapped.get("distance_km"))
|
||||
|
||||
wtype = str(activity_type).strip()
|
||||
iso = date_d.isoformat()
|
||||
_, workout_start_t = normalize_activity_start(start_key)
|
||||
@@ -869,8 +896,6 @@ def _import_activity(
|
||||
training_type_id, training_category, training_subcategory = _resolve_training_type_for_activity(
|
||||
cur, wtype, profile_id
|
||||
)
|
||||
mapped = apply_activity_mapped_column_aliases(cur, dict(mapped), training_category, training_type_id)
|
||||
# Nur Modul-Registry (Zielstruktur) + Mapping — keine parallelen hardcodierten CSV-Schlüssel.
|
||||
registry_updates = activity_csv_registry_updates_from_mapped(mapped)
|
||||
existing_id = find_activity_duplicate_id(cur, profile_id, iso, workout_start_t)
|
||||
|
||||
@@ -879,6 +904,12 @@ def _import_activity(
|
||||
"start_time": workout_start_t,
|
||||
"end_time": end_str or None,
|
||||
"activity_type": wtype,
|
||||
"duration_min": duration_min,
|
||||
"kcal_active": kcal_a,
|
||||
"kcal_resting": kcal_r,
|
||||
"hr_avg": hr_a,
|
||||
"hr_max": hr_m,
|
||||
"distance_km": dist,
|
||||
"training_type_id": training_type_id,
|
||||
"training_category": training_category,
|
||||
"training_subcategory": training_subcategory,
|
||||
@@ -899,12 +930,12 @@ def _import_activity(
|
||||
start_time=workout_start_t,
|
||||
end_time=end_str or None,
|
||||
activity_type=wtype,
|
||||
duration_min=registry_updates.get("duration_min"),
|
||||
kcal_active=registry_updates.get("kcal_active"),
|
||||
kcal_resting=registry_updates.get("kcal_resting"),
|
||||
hr_avg=registry_updates.get("hr_avg"),
|
||||
hr_max=registry_updates.get("hr_max"),
|
||||
distance_km=registry_updates.get("distance_km"),
|
||||
duration_min=duration_min,
|
||||
kcal_active=kcal_a,
|
||||
kcal_resting=kcal_r,
|
||||
hr_avg=hr_a,
|
||||
hr_max=hr_m,
|
||||
distance_km=dist,
|
||||
training_type_id=training_type_id,
|
||||
training_category=training_category,
|
||||
training_subcategory=training_subcategory,
|
||||
@@ -923,12 +954,12 @@ def _import_activity(
|
||||
str(aid),
|
||||
workout_date=iso,
|
||||
training_type_id=training_type_id,
|
||||
duration_min=registry_updates.get("duration_min"),
|
||||
hr_avg=registry_updates.get("hr_avg"),
|
||||
hr_max=registry_updates.get("hr_max"),
|
||||
distance_km=registry_updates.get("distance_km"),
|
||||
kcal_active=registry_updates.get("kcal_active"),
|
||||
kcal_resting=registry_updates.get("kcal_resting"),
|
||||
duration_min=duration_min,
|
||||
hr_avg=hr_a,
|
||||
hr_max=hr_m,
|
||||
distance_km=dist,
|
||||
kcal_active=kcal_a,
|
||||
kcal_resting=kcal_r,
|
||||
)
|
||||
upsert_session_metrics_from_csv_mapped(
|
||||
cur,
|
||||
|
||||
Reference in new issue
Block a user