feat(analytics): C1 命中列表默认过滤+批量处置
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -188,3 +188,32 @@ async def test_disposition_preserved(make_client):
|
||||
assert hit2.disposition == "false_positive"
|
||||
|
||||
await make_client(seed)
|
||||
|
||||
|
||||
# ------------------------------------------------------------- C1 命中列表/处置
|
||||
|
||||
async def test_hits_list_default_filter_and_dispose(make_client):
|
||||
async def seed(session):
|
||||
w = await words_svc.create_word(session, word="私单")
|
||||
session.add(SensitiveHit(word_id=w.id, msg_id="m1", channel="wechat",
|
||||
ts=1756900000000, snippet="…私单…",
|
||||
disposition="pending"))
|
||||
session.add(SensitiveHit(word_id=w.id, msg_id="m2", channel="wechat",
|
||||
ts=1756900001000, snippet="…私单…",
|
||||
disposition="ignored"))
|
||||
await session.commit()
|
||||
|
||||
client = await make_client(seed)
|
||||
r = await client.get("/api/analytics/sensitive/hits")
|
||||
body = r.json()
|
||||
assert body["total"] == 1 # 默认只 pending+confirmed
|
||||
ids = [h["id"] for h in body["items"]]
|
||||
r2 = await client.get("/api/analytics/sensitive/hits",
|
||||
params={"disposition": "ignored"})
|
||||
assert r2.json()["total"] == 1
|
||||
r3 = await client.patch("/api/analytics/sensitive/hits",
|
||||
json={"ids": ids, "disposition": "confirmed"})
|
||||
assert r3.json()["updated"] == 1
|
||||
r4 = await client.get("/api/analytics/sensitive/hits",
|
||||
params={"disposition": "confirmed"})
|
||||
assert r4.json()["total"] == 1
|
||||
|
||||
Reference in New Issue
Block a user