feat(matrix): 悬停里的每条视频显示自己的赞/评/藏/转
一格合并了多条时,并集只能说明「这天整体怎么样」,哪条是爆款要看每条自己的 数字。后端在 details 里带上各自的最近一轮指标,提示里缩进显示在该条标题下面。
This commit is contained in:
@@ -76,14 +76,19 @@ async def _task(platform: str = "dy", name: str = "矩阵测试") -> int:
|
||||
|
||||
|
||||
async def _note(
|
||||
task_id: int, note_id: str, name: str, published_at: int, creator_hash: str = "hash-a"
|
||||
task_id: int,
|
||||
note_id: str,
|
||||
name: str,
|
||||
published_at: int,
|
||||
creator_hash: str = "hash-a",
|
||||
title: str = "t",
|
||||
) -> None:
|
||||
async with monitor_db.get_session() as session:
|
||||
session.add(
|
||||
MonitorNote(
|
||||
task_id=task_id,
|
||||
note_id=note_id,
|
||||
title="t",
|
||||
title=title,
|
||||
note_url="",
|
||||
cover="",
|
||||
creator_hash=creator_hash,
|
||||
@@ -360,8 +365,8 @@ async def test_empty_stat_falls_back_to_the_note_name(db):
|
||||
async def test_cell_sums_the_latest_metric_of_each_note(db):
|
||||
task_id = await _task()
|
||||
now = get_current_timestamp() - 1000
|
||||
await _note(task_id, "n1", "博主A", now)
|
||||
await _note(task_id, "n2", "博主A", now)
|
||||
await _note(task_id, "n1", "博主A", now, title="作品一")
|
||||
await _note(task_id, "n2", "博主A", now, title="作品二")
|
||||
|
||||
# 同一篇有两轮快照,只取 run_id 最大的那一轮
|
||||
await _metric(task_id, "n1", run_id=1, liked=10, comment=1, collected=2, share=3)
|
||||
@@ -378,6 +383,16 @@ async def test_cell_sums_the_latest_metric_of_each_note(db):
|
||||
assert cell["collected"] == 5
|
||||
assert cell["shares"] == 5
|
||||
|
||||
# 逐条明细带**各自的**指标,不是格子的合计 —— 悬停时看的就是这个。
|
||||
by_title = {item["title"]: item for item in cell["details"]}
|
||||
assert by_title["作品一"]["likes"] == 20 # 取最近一轮
|
||||
assert by_title["作品一"]["comments"] == 2
|
||||
assert by_title["作品一"]["collected"] == 4
|
||||
assert by_title["作品一"]["shares"] == 5
|
||||
assert by_title["作品二"]["likes"] == 5
|
||||
assert by_title["作品二"]["comments"] is None # 未知不是 0
|
||||
assert by_title["作品二"]["shares"] == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_missing_metrics_are_none_not_zero(db):
|
||||
|
||||
Reference in New Issue
Block a user