51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
"""
|
|
Timeline API — REST endpoints over the TimelineStore journal.
|
|
"""
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from backend.analysis.timeline_store import STORE as TIMELINE_STORE
|
|
|
|
router = APIRouter(prefix="/timeline", tags=["timeline"])
|
|
|
|
|
|
# -----------------------------
|
|
# GET NODE TIMELINE
|
|
# -----------------------------
|
|
@router.get("/{node}")
|
|
def get_node_timeline(node: str):
|
|
return {
|
|
"node": node,
|
|
"events": TIMELINE_STORE.get_node_events(node),
|
|
}
|
|
|
|
|
|
# -----------------------------
|
|
# REWIND SNAPSHOT
|
|
# -----------------------------
|
|
@router.get("/rewind/{index}")
|
|
def rewind(index: int):
|
|
return {
|
|
"index": index,
|
|
"snapshot": TIMELINE_STORE.snapshot_at(index),
|
|
}
|
|
|
|
|
|
# -----------------------------
|
|
# STATS
|
|
# -----------------------------
|
|
@router.get("/stats/summary")
|
|
def stats():
|
|
return TIMELINE_STORE.stats()
|
|
|
|
|
|
# -----------------------------
|
|
# Legacy wrapper for api.py facade
|
|
# -----------------------------
|
|
def timeline_endpoint(session_id):
|
|
"""Legacy — return all events for a session id (or live journal if not found)."""
|
|
return {
|
|
"session_id": session_id,
|
|
"events": TIMELINE_STORE.all(),
|
|
}
|