feat(任务): 连续未命中 N 步跳过本账号(miss_limit)
- 任务级 miss_limit:连续 N 个叶子步骤 miss → 本账号剩余步骤跳过,换下一个号 - 成功一步清零;每个账号/每条内容重新计数;容器步骤不参与 - 编辑器顶部可填,保存进 params.miss_limit;计划任务段会带进计划任务 - 发布视频111 设 miss_limit=2 - 新增 test_miss_limit 用例;TASK_DEV / CHANGES 同步
This commit is contained in:
@@ -298,6 +298,9 @@ class GenericStepsWorker(BaseWorker):
|
||||
self.steps = p.get("steps", [])
|
||||
self._action_counts = {} # 步骤执行计数 {step_label: count}
|
||||
self._miss_counts = {} # 选择器健康:selector -> 连续未命中次数
|
||||
# 连续未命中策略(任务级 `miss_limit`,0=不启用):
|
||||
# 连续 N 步没命中就置 `_skip_rest` → 本账号剩余步骤不再执行,换下一个号。
|
||||
self._miss_streak = 0
|
||||
# 步骤路径:容器步骤(loop/group/if_el)进出时压栈,得到 "2.1.3" 这种位置,
|
||||
# 写进「步骤明细」用来还原嵌套结构。worker 每台设备一个线程,实例级状态安全。
|
||||
self._path = []
|
||||
@@ -449,6 +452,25 @@ class GenericStepsWorker(BaseWorker):
|
||||
_log.warning(f"[{self.serial}] 未知步骤类型: {stype}")
|
||||
result, detail = "unknown", f"未知步骤类型: {stype}"
|
||||
self._record_step(step, result, detail, int((time.time() - t0) * 1000))
|
||||
# 连续未命中:连续 `miss_limit` 步没命中 → 跳过本账号剩余步骤。
|
||||
# 只在**叶子操作**上累计/复位;容器步骤的返回值不代表命中(它的子步骤
|
||||
# 自己会走这里),否则会把刚攒起来的连续 miss 冲掉。
|
||||
_CONTAINERS = ("loop", "group", "if_el", "foreach_account",
|
||||
"foreach_item", "action_ref")
|
||||
if stype not in _CONTAINERS:
|
||||
if result == "miss":
|
||||
self._miss_streak += 1
|
||||
try:
|
||||
_limit = int(self.params.get("miss_limit") or 0)
|
||||
except (TypeError, ValueError):
|
||||
_limit = 0
|
||||
if _limit > 0 and self._miss_streak >= _limit:
|
||||
_log.warning(
|
||||
f"[{self.serial}] 连续 {self._miss_streak} 步未命中(miss_limit={_limit})"
|
||||
f" → 跳过本账号剩余步骤,换下一个号")
|
||||
self._skip_rest = True
|
||||
elif result == "ok":
|
||||
self._miss_streak = 0
|
||||
# 容器步骤(loop/group/if_el/foreach_account)不计入操作计数,避免监控显示噪音
|
||||
if stype not in ("loop", "group", "if_el", "foreach_account", "action_ref"):
|
||||
self._action_counts[label] = self._action_counts.get(label, 0) + 1
|
||||
@@ -2226,6 +2248,7 @@ class GenericStepsWorker(BaseWorker):
|
||||
self.set_action(f"发这个号的一条内容(第 {done + 1} 条:#{plan.get('seq')})")
|
||||
_log.info(f"[{self.serial}] 内容循环:『{target}』第 {done + 1} 条"
|
||||
f"({date} #{plan.get('seq')} {plan.get('title') or '(无标题)'})")
|
||||
self._miss_streak = 0 # 每条内容重新计连续未命中
|
||||
self._exec_steps(d, children, depth + 1)
|
||||
done += 1
|
||||
if self._break_loop: # 子步骤里有「跳出循环」→ 这个号的内容循环结束
|
||||
@@ -2295,6 +2318,7 @@ class GenericStepsWorker(BaseWorker):
|
||||
self._vars["target_name"] = target
|
||||
self.set_account(target) # 运行监测的"当前账号"
|
||||
self._skip_rest = False # 新一轮:复位"跳过剩余步骤"(上一轮某步判过页面不对)
|
||||
self._miss_streak = 0 # 新账号:连续未命中计数从 0 开始
|
||||
sent += 1
|
||||
self.set_action(f"第 {sent} 个号:{target}(本机还有 {len(names)} 个待发名字)")
|
||||
_log.info(f"[{self.serial}] 循环本机待发的号:轮到『{target}』"
|
||||
@@ -2395,6 +2419,7 @@ class GenericStepsWorker(BaseWorker):
|
||||
self.set_action(f"发这个号的一条内容(第 {done + 1} 条:#{plan.get('seq')})")
|
||||
_log.info(f"[{self.serial}] 内容循环:『{target}』第 {done + 1} 条"
|
||||
f"({date} #{plan.get('seq')} {plan.get('title') or '(无标题)'})")
|
||||
self._miss_streak = 0 # 每条内容重新计连续未命中
|
||||
self._exec_steps(d, children, depth + 1)
|
||||
done += 1
|
||||
if self._break_loop: # 子步骤里有「跳出循环」→ 这个号的内容循环结束
|
||||
@@ -2464,6 +2489,7 @@ class GenericStepsWorker(BaseWorker):
|
||||
self._vars["target_name"] = target
|
||||
self.set_account(target) # 运行监测的"当前账号"
|
||||
self._skip_rest = False # 新一轮:复位"跳过剩余步骤"(上一轮某步判过页面不对)
|
||||
self._miss_streak = 0 # 新账号:连续未命中计数从 0 开始
|
||||
sent += 1
|
||||
self.set_action(f"第 {sent} 个号:{target}(本机还有 {len(names)} 个待发名字)")
|
||||
_log.info(f"[{self.serial}] 循环本机待发的号:轮到『{target}』"
|
||||
|
||||
Reference in New Issue
Block a user