feat(analytics): E0-lite 数据健康端点——数据截至+实体新鲜度
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@ Includes:
|
||||
* ``GET /api/search`` (see :mod:`app.api.routers.search`).
|
||||
* ``GET /api/export/chat-html`` (see :mod:`app.api.routers.export`).
|
||||
* ``GET /api/staff-stats`` (see :mod:`app.api.routers.staff_stats`).
|
||||
* ``GET /api/analytics/health`` (see :mod:`app.api.routers.analytics`).
|
||||
|
||||
CORS is configured to read explicit allowed origins from ``Settings.cors_origins``
|
||||
(comma-separated ``CORS_ORIGINS`` env var). Empty (default) falls back to the dev
|
||||
@@ -42,6 +43,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.api.auth import require_auth
|
||||
from app.api.routers import (
|
||||
analytics,
|
||||
calls,
|
||||
customer,
|
||||
export,
|
||||
@@ -98,6 +100,7 @@ app.include_router(search.router)
|
||||
app.include_router(sessions.router)
|
||||
app.include_router(export.router)
|
||||
app.include_router(voice_clips.router)
|
||||
app.include_router(analytics.router)
|
||||
|
||||
|
||||
@app.get("/api/health")
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"""GET /api/analytics/* —— 数据分析板块端组(前缀分组=未来角色权限落点)。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Annotated, Any
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.analytics import health as health_svc
|
||||
from app.api.deps import get_session
|
||||
|
||||
router = APIRouter(prefix="/api/analytics", tags=["analytics"])
|
||||
|
||||
SessionDep = Annotated[AsyncSession, Depends(get_session)]
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
async def analytics_health(session: SessionDep) -> dict[str, Any]:
|
||||
"""E0-lite:数据截至 + 实体新鲜度。"""
|
||||
as_of = await health_svc.data_as_of(session)
|
||||
return {"data_as_of": as_of, "entities": await health_svc.entity_freshness(session)}
|
||||
Reference in New Issue
Block a user