fix(计划): 构建计划时读取 ae_profile 全局切号参数

- 新增 account_folder.current_profile()(读库 + 合并默认值)
- build_plan_job / ready_defaults 改用它,页面保存的切号选择器真正生效
- 手动按设备/账号跑也回落到 db 配置
- test_plan 增加 ae_profile 全局参数回归
This commit is contained in:
2026-10-31 09:22:26 +08:00
parent 7edb9f6a94
commit d5114dbf53
5 changed files with 52 additions and 7 deletions
+18 -2
View File
@@ -85,6 +85,22 @@ DEFAULT_PROFILE = {
}
def current_profile():
"""读 `ae_profile` 的**当前配置**并与默认值合并。
计划/调度在构建步骤时必须用这个,而不是 `merged()`(后者只看传入的 dict,
根本没读库)—— 否则页面「切号 / 发布前准备参数」里保存的全局值不会生效。
"""
from core.models import AeProfile
try:
with _ctx():
row = AeProfile.query.filter_by(id="default").first()
return merged(row.get_params() if row else None)
except Exception as e:
_log.debug("读取流水线配置失败(回落默认值): %s", e)
return merged()
def merged(profile=None):
"""把存下来的配置与默认值**深合并**(只补缺的键,用户填的优先)。"""
def _deep(base, over):
@@ -2169,7 +2185,7 @@ def run_account_once(account, action_id="", profile=None, serial=None, date="",
这里是**账号在外**(谁登着这个号谁跑),那里是**设备在外**(这台机器要跑哪几个号)。
"""
from core import video_plan as vp
prof = merged(profile)
prof = merged(profile) if profile else current_profile()
date = (date or "").strip() or vp._today()
run_id = (run_id or "").strip() or uuid.uuid4().hex[:12]
if not serial:
@@ -2264,7 +2280,7 @@ def _run_with_serial(serial, accounts, action_id, profile, date, run_id=""):
from core import video_plan as vp
from core.models import AeRun, CustomAction, AeApp, db
from tasks import get_task_class
prof = merged(profile)
prof = merged(profile) if profile else current_profile()
date = (date or "").strip() or vp._today()
run_id = (run_id or "").strip() or uuid.uuid4().hex[:12]
started = _now()
+4 -3
View File
@@ -594,11 +594,12 @@ def build_plan_job(plan, device, plan_run_id=""):
if segs:
opts["segment_apps"] = seg_apps
steps = af.build_segmented_steps(app_row.to_dict(), enriched,
af.merged(), account=device["accounts"][0],
opts=opts)
af.current_profile(),
account=device["accounts"][0], opts=opts)
else:
steps = af.build_run_steps(app_row.to_dict(), act.to_dict(),
af.merged(), account=device["accounts"][0], opts=opts)
af.current_profile(),
account=device["accounts"][0], opts=opts)
try:
miss_limit = max([int(e.get("miss_limit") or 0) for e in enriched] or [0])
except (TypeError, ValueError):