Merge branch 'dev' —— 通用计划统计修复

This commit is contained in:
2026-10-21 14:50:41 +08:00
3 changed files with 27 additions and 15 deletions
+4 -2
View File
@@ -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,
+7
View File
@@ -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,6 +775,8 @@ 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 = [], ""
totals = {}
if publish_mode:
for a in dev["accounts"]:
items += af._items_summary(a, date)
totals = af._totals(items)
+3
View File
@@ -902,5 +902,8 @@ data/accounts/周周苏州探店日记、周周苏州约会好去处/_日志/202
- 构建器实测「检测账号」:`require_pending=False`、children 10 个、accounts 2 个。
- 顺手把这个计划 `ready` 里存的旧昵称选择器(`tkv | tk+`)补成
`tk1 | tkv | tk+`(否则下一步切号回读还会 miss)。
- 收尾统计:不发布素材的计划不再拿 `video_plan` 的历史状态冒充本轮结果
(`_done` 按 `publish_mode` 跳过素材统计,`_finish_run` 显式收到空 items),
监控里不会再出现"只跑了亮屏却显示已发布 2 条"。
- 单测:`test_foreach_account.py` ⑦/⑧(通用模式没有素材也跑 / 发布模式仍然跳过)。
- 文档:TASK_DEV §4.4、ACCOUNT_FOLDER「发布素材」语义。