feat(analytics): E0-lite 数据健康端点——数据截至+实体新鲜度
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user