41 lines
709 B
Python
41 lines
709 B
Python
# api/timeline.py
|
|
|
|
from fastapi import APIRouter
|
|
from analysis.timeline_store import TimelineStore
|
|
|
|
router = APIRouter()
|
|
|
|
STORE = TimelineStore()
|
|
|
|
|
|
def get_store():
|
|
return STORE
|
|
|
|
|
|
# -----------------------------
|
|
# GET NODE TIMELINE
|
|
# -----------------------------
|
|
@router.get("/timeline/{node}")
|
|
def get_node_timeline(node: str):
|
|
|
|
store = get_store()
|
|
|
|
return {
|
|
"node": node,
|
|
"events": store.get_node_events(node)
|
|
}
|
|
|
|
|
|
# -----------------------------
|
|
# REWIND SNAPSHOT
|
|
# -----------------------------
|
|
@router.get("/timeline/rewind/{index}")
|
|
def rewind(index: int):
|
|
|
|
store = get_store()
|
|
|
|
return {
|
|
"index": index,
|
|
"snapshot": store.snapshot_at(index)
|
|
}
|