fix(计划): 通用步骤计划不再拿素材历史状态冒充本轮发布数
This commit is contained in:
@@ -2204,8 +2204,10 @@ def _finish_run(run_id, account, date, status, error="", serial="", device_name=
|
||||
"""
|
||||
from core.models import AeRun, db
|
||||
prof = merged(prof)
|
||||
items = items or _items_summary(account, date)
|
||||
totals = totals or _totals(items)
|
||||
# `None` = 没传(按素材表统计);显式传 [] 表示"这一轮不涉及素材"(通用任务计划),
|
||||
# 不能再用 `or` —— 那会把 [] 当成没传,又去素材表统计出误导性的已发布数。
|
||||
items = _items_summary(account, date) if items is None else items
|
||||
totals = _totals(items) if totals is None else totals
|
||||
accounts_for_log = [str(a).strip() for a in (log_accounts or [account] or [])
|
||||
if str(a).strip()]
|
||||
info = {"account": account, "date": date, "serial": serial, "device_name": device_name,
|
||||
|
||||
+20
-13
@@ -761,6 +761,11 @@ def _make_tracker(plan, prepared, plan_run_id, date, app_d, act_d):
|
||||
devices = [dev for _, dev in prepared]
|
||||
total = len(devices)
|
||||
|
||||
_segs = plan.get("segments") or []
|
||||
# 老计划(没有 segments)默认按发布流程统计;编排里所有段都不发布素材时,
|
||||
# 这轮根本不涉及素材,不能拿账号的 video_plan 历史状态冒充"已发布 N 条"。
|
||||
publish_mode = (not _segs) or any(bool(s.get("publish")) for s in _segs)
|
||||
|
||||
def _done(stats, outcomes, duration):
|
||||
try:
|
||||
with _ctx():
|
||||
@@ -770,19 +775,21 @@ def _make_tracker(plan, prepared, plan_run_id, date, app_d, act_d):
|
||||
st = {"success": "done", "skipped": "skipped",
|
||||
"stopped": "skipped"}.get(oc, "failed")
|
||||
items, err = [], ""
|
||||
for a in dev["accounts"]:
|
||||
items += af._items_summary(a, date)
|
||||
totals = af._totals(items)
|
||||
if totals.get("unknown"):
|
||||
st = "unknown"
|
||||
elif totals.get("failed") and not totals.get("published"):
|
||||
st = "failed"
|
||||
elif totals.get("pushed") and not totals.get("published"):
|
||||
# 推了素材但整轮没有一条回写"已发布" —— 多数是发布动作根本没跑到
|
||||
# (2026-10-18 实测:任务里的账号校验 miss → 整个发布 UI 被跳过)。
|
||||
# 别把这种轮次显示成"完成",否则用户以为发出去了。
|
||||
st = "failed"
|
||||
err = err or "素材已推送,但没有回写发布结果(检查发布动作/标记步骤)"
|
||||
totals = {}
|
||||
if publish_mode:
|
||||
for a in dev["accounts"]:
|
||||
items += af._items_summary(a, date)
|
||||
totals = af._totals(items)
|
||||
if totals.get("unknown"):
|
||||
st = "unknown"
|
||||
elif totals.get("failed") and not totals.get("published"):
|
||||
st = "failed"
|
||||
elif totals.get("pushed") and not totals.get("published"):
|
||||
# 推了素材但整轮没有一条回写"已发布" —— 多数是发布动作根本没跑到
|
||||
# (2026-10-18 实测:任务里的账号校验 miss → 整个发布 UI 被跳过)。
|
||||
# 别把这种轮次显示成"完成",否则用户以为发出去了。
|
||||
st = "failed"
|
||||
err = err or "素材已推送,但没有回写发布结果(检查发布动作/标记步骤)"
|
||||
try:
|
||||
from core.device_worker import get_all_worker_status
|
||||
for w in get_all_worker_status():
|
||||
|
||||
Reference in New Issue
Block a user