feat(report): 格子超过一条作品时,悬停显示逐条明细
并集看不出「哪个标签属于哪条视频」。现在格子里带 `details`(标题 + 各自的标签,
按发布时间正序),前端在超过 1 条时列出来:
1. 镇湖人绣东西… 大字报
2. 镇湖人绣东西… 养号
细节:
* 明细只在 count > 1 时展示;单条时并集本身就是那条的标签,再列一遍是噪音;
* 最多列 12 条,超出显示「…还有 N 条」—— 一天发几十条不至于把浮层撑爆;
* 标题用 textContent 写入,不当 HTML 解释;
* 标签仍按词表顺序排列。
测试:明细顺序与「各自带自己的标签」都有断言。
This commit is contained in:
@@ -1471,6 +1471,8 @@ async def daily_tag_matrix(
|
|||||||
"cells": {"2026-10-21": {"<hash>": {
|
"cells": {"2026-10-21": {"<hash>": {
|
||||||
"count": 2, "tags": ["大字报", "养号"],
|
"count": 2, "tags": ["大字报", "养号"],
|
||||||
"likes": 120, "comments": 8, "collected": 30, "shares": 4,
|
"likes": 120, "comments": 8, "collected": 30, "shares": 4,
|
||||||
|
"details": [{"title": "…", "tags": ["大字报"]},
|
||||||
|
{"title": "…", "tags": ["养号"]}], # 按发布时间正序
|
||||||
}}}}
|
}}}}
|
||||||
|
|
||||||
``likes/comments/collected/shares`` 是当天这些作品**最近一轮**指标的和;
|
``likes/comments/collected/shares`` 是当天这些作品**最近一轮**指标的和;
|
||||||
@@ -1515,6 +1517,7 @@ async def daily_tag_matrix(
|
|||||||
select(
|
select(
|
||||||
MonitorNote.task_id,
|
MonitorNote.task_id,
|
||||||
MonitorNote.note_id,
|
MonitorNote.note_id,
|
||||||
|
MonitorNote.title,
|
||||||
MonitorNote.creator_hash,
|
MonitorNote.creator_hash,
|
||||||
MonitorNote.creator_name,
|
MonitorNote.creator_name,
|
||||||
MonitorNote.published_at,
|
MonitorNote.published_at,
|
||||||
@@ -1625,9 +1628,17 @@ async def daily_tag_matrix(
|
|||||||
"comments": None,
|
"comments": None,
|
||||||
"collected": None,
|
"collected": None,
|
||||||
"shares": None,
|
"shares": None,
|
||||||
|
# 逐条明细:并集看不出「哪个标签属于哪条视频」,这里补上。
|
||||||
|
"details": [],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
bucket["count"] += 1
|
bucket["count"] += 1
|
||||||
|
bucket["details"].append(
|
||||||
|
{
|
||||||
|
"title": row.title or row.note_id,
|
||||||
|
"tags": list(tags_by_note.get(row.note_id, [])),
|
||||||
|
}
|
||||||
|
)
|
||||||
for tag in tags_by_note.get(row.note_id, []):
|
for tag in tags_by_note.get(row.note_id, []):
|
||||||
if tag not in bucket["tags"]:
|
if tag not in bucket["tags"]:
|
||||||
bucket["tags"].append(tag)
|
bucket["tags"].append(tag)
|
||||||
@@ -1649,6 +1660,8 @@ async def daily_tag_matrix(
|
|||||||
for day_cells in cells.values():
|
for day_cells in cells.values():
|
||||||
for bucket in day_cells.values():
|
for bucket in day_cells.values():
|
||||||
bucket["tags"].sort(key=lambda name: tag_order.get(name, 10**6))
|
bucket["tags"].sort(key=lambda name: tag_order.get(name, 10**6))
|
||||||
|
# 作品是按发布时间倒序取回来的,明细按时间正序更好读(1、2、3…)。
|
||||||
|
bucket["details"].reverse()
|
||||||
|
|
||||||
creators = [{"hash": hash_, "name": name} for hash_, name in known.items()]
|
creators = [{"hash": hash_, "name": name} for hash_, name in known.items()]
|
||||||
creators.sort(key=lambda item: item["name"])
|
creators.sort(key=lambda item: item["name"])
|
||||||
|
|||||||
@@ -188,6 +188,17 @@
|
|||||||
#tip .tip-metrics span { margin-right: 10px; white-space: nowrap; }
|
#tip .tip-metrics span { margin-right: 10px; white-space: nowrap; }
|
||||||
#tip .tip-metrics b { color: var(--muted); font-weight: 400; }
|
#tip .tip-metrics b { color: var(--muted); font-weight: 400; }
|
||||||
#tip .tip-tags { color: var(--muted); }
|
#tip .tip-tags { color: var(--muted); }
|
||||||
|
/* 逐条明细:并集看不出「哪个标签属于哪条视频」,这里补上。 */
|
||||||
|
#tip .tip-notes {
|
||||||
|
margin-top: 5px;
|
||||||
|
padding-top: 5px;
|
||||||
|
border-top: 1px solid var(--line);
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
#tip .tip-notes div { line-height: 1.55; }
|
||||||
|
#tip .tip-note-title { color: var(--text); }
|
||||||
|
#tip .tip-note-tags { color: var(--pink); margin-left: 6px; }
|
||||||
|
#tip .tip-note-more { color: var(--muted); }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -326,6 +337,35 @@
|
|||||||
tags.textContent =
|
tags.textContent =
|
||||||
'标签:' + (cell.tags && cell.tags.length ? cell.tags.join(' / ') : '无标签');
|
'标签:' + (cell.tags && cell.tags.length ? cell.tags.join(' / ') : '无标签');
|
||||||
tip.appendChild(tags);
|
tip.appendChild(tags);
|
||||||
|
|
||||||
|
// 一格合并了多条作品时,并集看不出「哪个标签属于哪条视频」,逐条列出来。
|
||||||
|
const details = cell.details || [];
|
||||||
|
if (details.length > 1) {
|
||||||
|
const list = document.createElement('div');
|
||||||
|
list.className = 'tip-notes';
|
||||||
|
const limit = 12;
|
||||||
|
for (let index = 0; index < Math.min(details.length, limit); index += 1) {
|
||||||
|
const item = details[index];
|
||||||
|
const row = document.createElement('div');
|
||||||
|
const title = document.createElement('span');
|
||||||
|
title.className = 'tip-note-title';
|
||||||
|
title.textContent = index + 1 + '. ' + item.title;
|
||||||
|
row.appendChild(title);
|
||||||
|
const noteTags = document.createElement('span');
|
||||||
|
noteTags.className = 'tip-note-tags';
|
||||||
|
noteTags.textContent =
|
||||||
|
item.tags && item.tags.length ? item.tags.join(' / ') : '无标签';
|
||||||
|
row.appendChild(noteTags);
|
||||||
|
list.appendChild(row);
|
||||||
|
}
|
||||||
|
if (details.length > limit) {
|
||||||
|
const more = document.createElement('div');
|
||||||
|
more.className = 'tip-note-more';
|
||||||
|
more.textContent = '…还有 ' + (details.length - limit) + ' 条';
|
||||||
|
list.appendChild(more);
|
||||||
|
}
|
||||||
|
tip.appendChild(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTip(event) {
|
function showTip(event) {
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ async def test_two_notes_with_different_tags_merge_into_one_cell(db):
|
|||||||
cell = data["cells"][_day(now)]["hash-a"]
|
cell = data["cells"][_day(now)]["hash-a"]
|
||||||
assert cell["count"] == 2
|
assert cell["count"] == 2
|
||||||
assert cell["tags"] == ["大字报", "养号"]
|
assert cell["tags"] == ["大字报", "养号"]
|
||||||
|
# 逐条明细按发布时间正序:先发的在前,各自带自己的标签
|
||||||
|
assert [item["tags"] for item in cell["details"]] == [["大字报"], ["养号"]]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|||||||
Reference in New Issue
Block a user