fix(automation): 租约巡检降为4小时并收紧首次登录样本
- lease_bound 30 分钟会超出 ck_health 吞吐,改为 240 分钟 - 首次登录样本排除缺账号/密码和已判极验/凭证失败的账号 - 补充保护组和首登样本准入测试
This commit is contained in:
+8
-1
@@ -281,7 +281,7 @@ CK 本体和健康结果都在账号上:
|
|||||||
- 成员:`account_leases.status=active` 且 purpose 为
|
- 成员:`account_leases.status=active` 且 purpose 为
|
||||||
`platform_fulfillment` / `douyu_collab`;
|
`platform_fulfillment` / `douyu_collab`;
|
||||||
- 默认开启;
|
- 默认开启;
|
||||||
- 巡检间隔 30 分钟(比普通账号更短);
|
- 巡检间隔 240 分钟(比普通账号更短,且不挤占 ck_health 吞吐);
|
||||||
- 自动重登开启。
|
- 自动重登开启。
|
||||||
|
|
||||||
这样所有生效租约账号都会进入 CK 巡检和失效重登保护,不再只覆盖预售/协作单。
|
这样所有生效租约账号都会进入 CK 巡检和失效重登保护,不再只覆盖预售/协作单。
|
||||||
@@ -308,3 +308,10 @@ CK 本体和健康结果都在账号上:
|
|||||||
|
|
||||||
租约账号在履约期间 CK 失效会出现不可用窗口;提前登录可以把窗口前移到空闲时段。
|
租约账号在履约期间 CK 失效会出现不可用窗口;提前登录可以把窗口前移到空闲时段。
|
||||||
作业不直接改绑定或订单,只刷新 Cookie。
|
作业不直接改绑定或订单,只刷新 Cookie。
|
||||||
|
|
||||||
|
|
||||||
|
### 首次登录样本
|
||||||
|
|
||||||
|
`account_onboarding` 保持默认关闭。先点“立即跑一次”跑 20 个样本,不打开自动作业;
|
||||||
|
样本账号会排除缺账号/密码和已判定极验/凭证失败的账号,避免样本被必失败账号污染。
|
||||||
|
确认成功率、失败分型和登录后商品能力同步后,再启用作业放量。
|
||||||
|
|||||||
@@ -70,6 +70,19 @@ def test_selector_only_picks_unlogged_automatable_accounts(db):
|
|||||||
assert job.count_pending_onboarding(db) == 1
|
assert job.count_pending_onboarding(db) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_selector_skips_missing_password_and_manual_failure(db):
|
||||||
|
_admin(db)
|
||||||
|
selectable = _account("onboarding-eligible")
|
||||||
|
missing_password = _account("onboarding-no-password", password="")
|
||||||
|
manual_failure = _account("onboarding-captcha", relogin_failure_kind="captcha")
|
||||||
|
db.add_all([selectable, missing_password, manual_failure])
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
rows = job.build_select_query(db, _job()).all()
|
||||||
|
|
||||||
|
assert [row.id for row in rows] == [selectable.id]
|
||||||
|
|
||||||
|
|
||||||
def test_run_account_onboarding_returns_batch_summary(db, monkeypatch):
|
def test_run_account_onboarding_returns_batch_summary(db, monkeypatch):
|
||||||
_admin(db)
|
_admin(db)
|
||||||
first = _account("onboarding-first")
|
first = _account("onboarding-first")
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ def test_lease_bound_includes_all_active_lease_purposes(db):
|
|||||||
assert snapshot.group_account_ids["lease_bound"] == frozenset(
|
assert snapshot.group_account_ids["lease_bound"] == frozenset(
|
||||||
{leased.id, collab_leased.id}
|
{leased.id, collab_leased.id}
|
||||||
)
|
)
|
||||||
assert snapshot.groups["lease_bound"]["probe_interval_minutes"] == 30
|
assert snapshot.groups["lease_bound"]["probe_interval_minutes"] == 240
|
||||||
assert leased.id in snapshot.relogin_ids
|
assert leased.id in snapshot.relogin_ids
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ GROUP_DEFINITIONS: dict[str, dict[str, Any]] = {
|
|||||||
"description": "当前所有生效的直播履约/协作租约账号,优先 CK 巡检和到期前刷新",
|
"description": "当前所有生效的直播履约/协作租约账号,优先 CK 巡检和到期前刷新",
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
"target_count": 0,
|
"target_count": 0,
|
||||||
"probe_interval_minutes": 30,
|
"probe_interval_minutes": 240,
|
||||||
"auto_relogin": True,
|
"auto_relogin": True,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from sqlalchemy import func, or_, select
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from ....models import Account, AutomationJob, LoginTask
|
from ....models import Account, AutomationJob, LoginTask
|
||||||
from ...account_lifecycle import MANUAL_STATES, STATUS_MANUAL
|
from ...account_lifecycle import MANUAL_KINDS, MANUAL_STATES, STATUS_MANUAL
|
||||||
from ...login_automation import run_login_batch_with_fallback, system_user_id
|
from ...login_automation import run_login_batch_with_fallback, system_user_id
|
||||||
|
|
||||||
JOB_KEY = "account_onboarding"
|
JOB_KEY = "account_onboarding"
|
||||||
@@ -38,6 +38,13 @@ def build_select_query(
|
|||||||
.filter(
|
.filter(
|
||||||
Account.auto_managed.is_(True),
|
Account.auto_managed.is_(True),
|
||||||
Account.status.notin_((*MANUAL_STATES, STATUS_MANUAL)),
|
Account.status.notin_((*MANUAL_STATES, STATUS_MANUAL)),
|
||||||
|
# 缺账号/密码的账号首登必失败,不能占样本名额。
|
||||||
|
Account.username != "",
|
||||||
|
Account.password != "",
|
||||||
|
# 已经判定为极验/凭证问题的账号不再自动首登。
|
||||||
|
func.coalesce(Account.relogin_failure_kind, "").notin_(
|
||||||
|
tuple(sorted(MANUAL_KINDS))
|
||||||
|
),
|
||||||
or_(Account.cookie.is_(None), Account.cookie == ""),
|
or_(Account.cookie.is_(None), Account.cookie == ""),
|
||||||
~_in_flight_login_exists(),
|
~_in_flight_login_exists(),
|
||||||
)
|
)
|
||||||
@@ -53,6 +60,11 @@ def count_pending_onboarding(db: Session) -> int:
|
|||||||
.filter(
|
.filter(
|
||||||
Account.auto_managed.is_(True),
|
Account.auto_managed.is_(True),
|
||||||
Account.status.notin_((*MANUAL_STATES, STATUS_MANUAL)),
|
Account.status.notin_((*MANUAL_STATES, STATUS_MANUAL)),
|
||||||
|
Account.username != "",
|
||||||
|
Account.password != "",
|
||||||
|
func.coalesce(Account.relogin_failure_kind, "").notin_(
|
||||||
|
tuple(sorted(MANUAL_KINDS))
|
||||||
|
),
|
||||||
or_(Account.cookie.is_(None), Account.cookie == ""),
|
or_(Account.cookie.is_(None), Account.cookie == ""),
|
||||||
~_in_flight_login_exists(),
|
~_in_flight_login_exists(),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user