diff --git a/api/monitor/superdir.py b/api/monitor/superdir.py index 1e02db8..3af3010 100644 --- a/api/monitor/superdir.py +++ b/api/monitor/superdir.py @@ -402,6 +402,19 @@ async def preview( "start": start_day.isoformat(), "end": end_day.isoformat(), "activities": len(activities), + # 匹配到的活动原样带回去。**0 条作品时它就是唯一能解释为什么的东西**: + # 活动建了但还没人发布(尤其是排期在未来的活动),界面不能只显示一个「0」。 + # 注意活动名里的日期("10.23")是活动名,不是创建时间 —— 这两者经常被当成一回事。 + "matched_activities": [ + { + "id": _as_int(activity.get("id")), + "title": str(activity.get("title") or ""), + "created_at": _as_int(activity.get("created_at")), + "total_count": _as_int(activity.get("total_count")), + "published_count": _as_int(activity.get("published_count")), + } + for activity in activities + ], "videos": total, "creators": len({row["nickname"] for row in rows if row["nickname"]}), "skipped": skipped, diff --git a/tests/test_monitor_superdir.py b/tests/test_monitor_superdir.py index b458de1..949b6a7 100644 --- a/tests/test_monitor_superdir.py +++ b/tests/test_monitor_superdir.py @@ -86,6 +86,49 @@ class TestPreview: assert result["videos"] == 1 assert result["rows"][0]["aweme_id"] == AWEME_A + @pytest.mark.asyncio + async def test_matched_activities_explain_a_zero_video_result(self, monkeypatch): + """活动建了但还没人发布 —— 0 条作品是真的,界面上得说得出是哪几个活动。 + + 实测踩到过:运营按「10-22 ~ 10-24」查,返回 4 个活动、0 条作品,以为链接没取到。 + 那 4 个活动全是排期在未来的(10.26/10.27/10.28/10.29),当然还没有作品。 + """ + + async def fake_activities(token, client): + return [ + { + "id": 9, + "title": "10.26 漫展", + "created_at": superdir._day_start(date(2026, 10, 22)) + 3600, + "total_count": 0, + "published_count": 0, + } + ] + + async def fake_videos(token, activity_id, client): + return [] + + async def fake_token(session, platform=superdir.adapters.PLATFORM_DY): + return "token" + + monkeypatch.setattr(superdir, "_fetch_activities", fake_activities) + monkeypatch.setattr(superdir, "_fetch_videos", fake_videos) + monkeypatch.setattr(superdir, "get_token", fake_token) + + result = await superdir.preview(None, "2026-10-22", "2026-10-24") + + assert result["videos"] == 0 + assert result["rows"] == [] + assert result["matched_activities"] == [ + { + "id": 9, + "title": "10.26 漫展", + "created_at": superdir._day_start(date(2026, 10, 22)) + 3600, + "total_count": 0, + "published_count": 0, + } + ] + @pytest.mark.asyncio async def test_unpublished_and_private_videos_are_skipped(self, monkeypatch): async def fake_activities(token, client): diff --git a/webui/src/components/monitor/SuperDirTool.tsx b/webui/src/components/monitor/SuperDirTool.tsx index cd5e4e5..4c7fc56 100644 --- a/webui/src/components/monitor/SuperDirTool.tsx +++ b/webui/src/components/monitor/SuperDirTool.tsx @@ -208,9 +208,28 @@ export function SuperDirTool({ open, onOpenChange }: SuperDirToolProps) { ))} ) : ( -
- 这段时间里没有可导入的作品 -
++ 这段时间创建了 {data.matched_activities.length} 个分发活动,但还没有已发布的作品: +
+ {data.matched_activities.map((activity) => ( ++ 活动名里的日期只是活动名,不是创建时间;排期在未来的活动通常还没有作品。 +
+