feat(analytics): E0-lite 数据健康端点——数据截至+实体新鲜度

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-04 15:37:13 +08:00
parent 8b29326b2e
commit 0b1d377db7
5 changed files with 116 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""/api/analytics/health:E0-lite 冒烟。"""
from __future__ import annotations
from app.db.models import MsgDailyStats
async def test_health_empty(make_client):
async def seed(session):
...
client = await make_client(seed)
r = await client.get("/api/analytics/health")
assert r.status_code == 200
body = r.json()
assert body["data_as_of"] is None
assert any(e["table"] == "message" for e in body["entities"])
async def test_health_with_stats(make_client):
async def seed(session):
session.add(
MsgDailyStats(
channel="wechat",
owner_account_id="wx1",
peer_kind="friend",
peer_id="t1",
day=20260904,
send_cnt=1,
recv_cnt=2,
last_ts=1756900000000,
last_is_send=False,
)
)
await session.commit()
client = await make_client(seed)
r = await client.get("/api/analytics/health")
assert r.status_code == 200
assert r.json()["data_as_of"] == 1756900000000