From 0c3fc9f68e979c7bf375e02d08e44bfe514e7000 Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 15 Aug 2026 08:37:31 -0500 Subject: [PATCH] =?UTF-8?q?fix(test1):=20X=E7=AB=8B=E5=8D=B3=E5=8F=96?= =?UTF-8?q?=E6=A0=B7=E6=8F=90=E7=A4=BA=E5=8C=BA=E5=88=86=E3=80=8C=E4=BB=8A?= =?UTF-8?q?=E6=97=A5=E5=B7=B2=E5=8F=96=E6=A0=B7=E3=80=8D=E4=B8=8E=E7=9C=9F?= =?UTF-8?q?=E6=97=A0=E5=80=99=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当前在播房同日去重后返回 all_deduped,不再误报 no_candidates。 Co-authored-by: Cursor --- backend/app/x_clips_pipeline.py | 27 ++++++++++++++++++++++++--- frontend/src/app/x/ClipsPanel.tsx | 13 ++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/backend/app/x_clips_pipeline.py b/backend/app/x_clips_pipeline.py index 297cdda..f266872 100644 --- a/backend/app/x_clips_pipeline.py +++ b/backend/app/x_clips_pipeline.py @@ -174,21 +174,42 @@ def sample_live_now() -> dict[str, Any]: settings = db.get_settings_map() if not settings.get("x_clips_enabled"): return {"enqueued": 0, "live_count": 0, "skipped_dedupe": 0, "job_ids": [], "reason": "x_clips_disabled"} + # Manual sample must run even if periodic live_sample switch is off + patched = {**settings, "x_clips_live_sample": True} rooms = db.list_live_douyin_rooms_for_shorts(limit=400) day = push_date_from_ts(time.time()) skipped = 0 + eligible = 0 + any_live = bool(patched.get("x_clips_sample_any_live", True)) for room in rooms: rid = str(room.get("room_id") or "") - if rid and x_clips_db.has_x_clip_job_for_room_day(rid, day): + if not rid: + continue + if patched.get("x_clips_dedupe_room_day", True) and x_clips_db.has_x_clip_job_for_room_day(rid, day): skipped += 1 - n = try_sample_live_rooms(settings) + continue + if any_live or _room_eligible(room, patched): + eligible += 1 + n = try_sample_live_rooms(patched) jobs = x_clips_db.list_pending_x_clip_jobs(limit=20) + reason = "" + if n: + reason = "" + elif x_clips_db.x_clips_quota_gap(cfg=patched) <= 0: + reason = "no_quota" + elif skipped and skipped >= len(rooms) and len(rooms) > 0: + reason = "all_deduped" + elif eligible <= 0: + reason = "no_candidates" + else: + reason = "enqueue_failed" return { "enqueued": n, "live_count": len(rooms), "skipped_dedupe": skipped, + "eligible": eligible, "job_ids": [str(j.get("id")) for j in jobs], - "reason": "" if n else ("no_quota" if x_clips_db.x_clips_quota_gap(cfg=settings) <= 0 else "no_candidates"), + "reason": reason, } diff --git a/frontend/src/app/x/ClipsPanel.tsx b/frontend/src/app/x/ClipsPanel.tsx index 686ce86..f6b035f 100644 --- a/frontend/src/app/x/ClipsPanel.tsx +++ b/frontend/src/app/x/ClipsPanel.tsx @@ -282,7 +282,18 @@ export function ClipsPanel({ onClick={() => void run(async () => { const r = await fetchJson("/api/x-clips/sample-now", { method: "POST" }); - if (!r?.enqueued) throw new Error(r?.reason || "未入队(可能无在播或配额满)"); + const enq = Number(r?.enqueued || 0); + if (enq > 0) return; + const reason = String(r?.reason || ""); + const live = Number(r?.live_count || 0); + const skip = Number(r?.skipped_dedupe || 0); + if (reason === "all_deduped") { + throw new Error(`今日在播房间都已取样过(${skip}/${live}),同房同日不重复`); + } + if (reason === "no_quota") throw new Error("今日配额已满"); + if (reason === "x_clips_disabled") throw new Error("请先开启自动切片"); + if (reason === "no_candidates") throw new Error(`无可用在播房间(在播 ${live})`); + throw new Error(reason || "未入队"); }, "取样完成") } >