refactor: Remove source field handling from activity session metrics logic
Deploy Development / deploy (push) Successful in 54s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Eliminated checks for `source_field` in the `replace_activity_session_metrics` function to streamline EAV row replacement, ensuring consistency with existing logic.
- Updated frontend logic to simplify the filtering of metrics during payload construction, enhancing maintainability.
- Removed outdated unit tests related to `source_field` handling, reflecting the updated logic in the codebase.
This commit is contained in:
Lars committed 2026-04-16 12:35:55 +02:00
1 parent 94bb4a8199
commit 2a26e4fecf
3 files changed
+2 -104

No files matched your search

@@ -505,9 +505,6 @@ def replace_activity_session_metrics(
) -> List[Dict[str, Any]]:
"""
Full replace of EAV rows for this session. metrics: [{ "parameter_key": str, "value": ... }, ...]
Parameter mit gesetztem ``source_field`` werden nicht in EAV persistiert (kanonisch ``activity_log``),
konsistent zu ``upsert_session_metrics_from_csv_mapped`` — verhindert doppelte Speicherung nach PUT.
"""
cur.execute(
"""
@@ -538,9 +535,6 @@ def replace_activity_session_metrics(
if not s["required"]:
continue
itk = s["key"]
sf_req = s.get("source_field")
if sf_req is not None and str(sf_req).strip():
continue
hit = payload_by_key.get(itk)
if hit is None or hit.get("value") is None:
raise ActivitySessionMetricsError(400, f"Pflichtfeld fehlt: {itk}")
@@ -553,9 +547,6 @@ def replace_activity_session_metrics(
for item in metrics:
k = str(item["parameter_key"]).strip()
spec = by_key[k]
sf_raw = spec.get("source_field")
if sf_raw is not None and str(sf_raw).strip():
continue
val = item.get("value")
if val is None:
if spec["required"]: