feat: Update activity documentation and enhance API responses with session metrics
- Added new updates for Phase A and Phase B in `CLAUDE.md`, detailing the completion of Phase A and the introduction of enriched session metrics in the API response for `GET /api/activity`. - Enhanced the README to include references to new documentation files for scalar canon and composite metrics implementation. - Updated `ACTIVITY_PRODUCTION_ARCHITECTURE_AND_PHASES.md` to reflect the current status of phases and added navigation rules for data access. - Improved `ACTIVITY_SESSION_METRICS_EAV_AGENT_GUIDE.md` with links to new implementation concepts for composite metrics. - Refactored the activity router to integrate enriched session metrics into the activity list responses, ensuring a more comprehensive data presentation.
This commit is contained in:
1 parent
cc0f57758a
commit
fa3e66fb31
9 files changed
+1956
-16
No files matched your search
@@ -6,7 +6,8 @@ Kanonische Aufteilung activity_log vs. EAV für Aktivitätssessions.
|
||||
- **Alle anderen Attribute:** ``training_parameters`` + Attributprofil (Kategorie/Typ) → EAV;
|
||||
Lesefallback für bekannte Legacy-Spalten siehe unten.
|
||||
|
||||
Normative Doku: .claude/docs/technical/ACTIVITY_PRODUCTION_ARCHITECTURE_AND_PHASES.md
|
||||
Normative Doku: .claude/docs/technical/ACTIVITY_PRODUCTION_ARCHITECTURE_AND_PHASES.md,
|
||||
ACTIVITY_SCALAR_KANON_TABLE.md
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ from data_layer.activity_persistence_orchestrator import (
|
||||
new_activity_id,
|
||||
)
|
||||
from data_layer.activity_time_normalize import normalize_activity_start
|
||||
from data_layer.activity_session_metrics import enrich_sessions_with_metrics
|
||||
|
||||
router = APIRouter(prefix="/api/activity", tags=["activity"])
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -71,6 +72,12 @@ def _activity_rows_after_list_query(cur):
|
||||
return rows
|
||||
|
||||
|
||||
def _return_activity_list_rows(cur, rows: list) -> list:
|
||||
"""Layer-1: gemergte session_metrics wie Detail-Pfad (Batch)."""
|
||||
enrich_sessions_with_metrics(cur, rows)
|
||||
return rows
|
||||
|
||||
|
||||
# Evaluation import with error handling (Phase 1.2)
|
||||
try:
|
||||
from evaluation_helper import evaluate_and_save_activity
|
||||
@@ -140,7 +147,7 @@ def list_activity(
|
||||
""",
|
||||
(pid, d0, d1, limit),
|
||||
)
|
||||
return _activity_rows_after_list_query(cur)
|
||||
return _return_activity_list_rows(cur, _activity_rows_after_list_query(cur))
|
||||
cur.execute(
|
||||
f"""
|
||||
SELECT * FROM activity_log
|
||||
@@ -152,7 +159,9 @@ def list_activity(
|
||||
""",
|
||||
(pid, d0, d1, limit),
|
||||
)
|
||||
return [r2d(r) for r in cur.fetchall()]
|
||||
return _return_activity_list_rows(
|
||||
cur, [r2d(r) for r in cur.fetchall()]
|
||||
)
|
||||
|
||||
if days is not None:
|
||||
if collapse_duplicate_sessions:
|
||||
@@ -173,7 +182,7 @@ def list_activity(
|
||||
""",
|
||||
(pid, days, limit, offset),
|
||||
)
|
||||
return _activity_rows_after_list_query(cur)
|
||||
return _return_activity_list_rows(cur, _activity_rows_after_list_query(cur))
|
||||
cur.execute(
|
||||
f"""
|
||||
SELECT * FROM activity_log
|
||||
@@ -203,7 +212,7 @@ def list_activity(
|
||||
""",
|
||||
(pid, limit, offset),
|
||||
)
|
||||
return _activity_rows_after_list_query(cur)
|
||||
return _return_activity_list_rows(cur, _activity_rows_after_list_query(cur))
|
||||
cur.execute(
|
||||
f"""
|
||||
SELECT * FROM activity_log
|
||||
@@ -214,7 +223,7 @@ def list_activity(
|
||||
""",
|
||||
(pid, limit, offset),
|
||||
)
|
||||
return [r2d(r) for r in cur.fetchall()]
|
||||
return _return_activity_list_rows(cur, [r2d(r) for r in cur.fetchall()])
|
||||
|
||||
|
||||
@router.post("")
|
||||
|
||||
Reference in new issue
Block a user