feat(automation): CK 自动重登(P1b)+ 失败分型与待人工队列
P1a 的巡检只产出「谁失效了」的清单,不兑现修复:1,356 个失效账号仍要人工逐个
选集→点重登→过滑块。线上实测 20 个失效账号重登 20/20 成功(2 分 13 秒、零极验),
证实失效是会话级过期而非凭证问题,可救量约 1,350。
后端:
- 迁移 20261002_0038:login_tasks 加 relogin_failure_kind(枚举),供作业决定
「继续退避重试」还是「转人工」;不用 attempt_message 做字符串匹配(文案一改
就失效,页面也要按类型筛选);
- jobs/ck_relogin.py:
- 候选 = 巡检判定 invalid + 允许自动管理 + 无在途尝试 + 退避到期 + 未超每日上限
+ **未转人工**(极验/凭证问题不再自动重登);
- 复用 LoginBatchRunner(mode="relogin"),成功才替换 CK(沿用既有安全语义)。
自动化身份取最早的超管做 created_by,权限给 login:view_all 以免受归属限制;
总时长上限压到 240 秒,避免长时间占住调度线程;
- settle_results() 独立成纯函数便于单测:成功清空退避状态;失败按分型分流 ——
captcha/credential 转人工(不排期)、email_quota 退避到次日零点+随机抖动、
email_code/interrupted/network 走 1h→3h→12h→24h 阶梯;次数用尽也停下等人工;
- 未知文案默认按可重试处理(有每日上限兜底),别把可能只是抖动的账号推给人工;
- 注册第二个作业「CK 自动重登」(batch 10 / 并发 3,**默认关闭**);
- 新增 GET /api/automation/manual-queue:按原因分组列出待人工处理的账号。可重试
类型但已无下次排期的(次数用尽)单独成组 —— 否则会混进「验证码失败」里,客服
看不出这个已经不会再自动试了。
前端:
- /automation 页新增「待人工处理」卡片,按分型分组展示(极验要过滑块、凭证要核对、
次数用尽要人工确认),各带账号与最近失败原因。
测试:新增 26 条(分型顺序陷阱「上限」优先于「验证码」、退避阶梯、配额退避次日、
候选筛选、MySQL 方言编译、结算、待人工队列分组)。
提交前全量 297 通过、ruff 全绿、前端 tsc 通过。
注意:提交时另一路「测试改用 MySQL」的改造正在同一工作区进行,本次刻意只暂存
本功能相关文件,未触碰 tests/conftest.py、tests/support/ 及对方已转换的测试文件。
This commit is contained in:
@@ -1,18 +1,35 @@
|
||||
import api from './client';
|
||||
import api from "./client";
|
||||
import type {
|
||||
AutomationJobItem,
|
||||
AutomationManualQueue,
|
||||
AutomationJobUpdate,
|
||||
AutomationJobsResponse,
|
||||
AutomationRunOutcome,
|
||||
AutomationRunsResponse,
|
||||
} from './types';
|
||||
} from "./types";
|
||||
|
||||
export const automationApi = {
|
||||
jobs: () => api.get<AutomationJobsResponse, AutomationJobsResponse>('/automation/jobs'),
|
||||
jobs: () =>
|
||||
api.get<AutomationJobsResponse, AutomationJobsResponse>("/automation/jobs"),
|
||||
updateJob: (key: string, payload: AutomationJobUpdate) =>
|
||||
api.patch<AutomationJobItem, AutomationJobItem>(`/automation/jobs/${key}`, payload),
|
||||
api.patch<AutomationJobItem, AutomationJobItem>(
|
||||
`/automation/jobs/${key}`,
|
||||
payload,
|
||||
),
|
||||
runJob: (key: string) =>
|
||||
api.post<AutomationRunOutcome, AutomationRunOutcome>(`/automation/jobs/${key}/run`),
|
||||
api.post<AutomationRunOutcome, AutomationRunOutcome>(
|
||||
`/automation/jobs/${key}/run`,
|
||||
),
|
||||
runs: (params: { job_key?: string; limit?: number }) =>
|
||||
api.get<AutomationRunsResponse, AutomationRunsResponse>('/automation/runs', { params }),
|
||||
api.get<AutomationRunsResponse, AutomationRunsResponse>(
|
||||
"/automation/runs",
|
||||
{ params },
|
||||
),
|
||||
manualQueue: (limit = 20) =>
|
||||
api.get<AutomationManualQueue, AutomationManualQueue>(
|
||||
"/automation/manual-queue",
|
||||
{
|
||||
params: { limit },
|
||||
},
|
||||
),
|
||||
};
|
||||
|
||||
@@ -174,7 +174,7 @@ export interface YybTask {
|
||||
created_by: number;
|
||||
created_by_username?: string;
|
||||
provider: string;
|
||||
platform: 'android' | 'ios';
|
||||
platform: "android" | "ios";
|
||||
points: number | null;
|
||||
price_fen?: number | null;
|
||||
product_id: string;
|
||||
@@ -185,7 +185,10 @@ export interface YybTask {
|
||||
status: string;
|
||||
phase: string;
|
||||
message: string;
|
||||
result: { logs?: string[]; payment_status?: Record<string, unknown> | null } | null;
|
||||
result: {
|
||||
logs?: string[];
|
||||
payment_status?: Record<string, unknown> | null;
|
||||
} | null;
|
||||
login_qr_data?: string;
|
||||
login_qr_mime_type?: string;
|
||||
payment_qr_data?: string;
|
||||
@@ -198,10 +201,22 @@ export interface YybTask {
|
||||
}
|
||||
|
||||
export interface YybSelectionOptions {
|
||||
products: Array<{ points: number; product_id: string; price_fen: number; offer_id: string; name: string }>;
|
||||
products: Array<{
|
||||
points: number;
|
||||
product_id: string;
|
||||
price_fen: number;
|
||||
offer_id: string;
|
||||
name: string;
|
||||
}>;
|
||||
zones: Array<{ zone_id: string; name: string }>;
|
||||
roles: Array<{ role_id: string; name: string; ban_status: string }>;
|
||||
default_product: { points: number; product_id: string; price_fen: number; offer_id: string; name: string } | null;
|
||||
default_product: {
|
||||
points: number;
|
||||
product_id: string;
|
||||
price_fen: number;
|
||||
offer_id: string;
|
||||
name: string;
|
||||
} | null;
|
||||
default_zone: { zone_id: string; name: string } | null;
|
||||
}
|
||||
|
||||
@@ -280,7 +295,7 @@ export interface CookieOperationItem {
|
||||
ck_check_status: string;
|
||||
ck_checked_at: string | null;
|
||||
created_at: string | null;
|
||||
relogin_status: '' | 'relogin_pending' | 'relogin_running' | 'relogin_failed';
|
||||
relogin_status: "" | "relogin_pending" | "relogin_running" | "relogin_failed";
|
||||
relogin_message: string;
|
||||
relogin_batch_id: string;
|
||||
}
|
||||
@@ -379,7 +394,7 @@ export interface DouyuConfig {
|
||||
xpd_act_id: string;
|
||||
xpd_rid: string;
|
||||
gold_pay_type: number;
|
||||
gold_recharge_channel: 'wechat_qr' | 'supplier_api';
|
||||
gold_recharge_channel: "wechat_qr" | "supplier_api";
|
||||
gold_api_product_id: string;
|
||||
gold_api_account_template_name: string;
|
||||
gift_id: string;
|
||||
@@ -388,13 +403,13 @@ export interface DouyuConfig {
|
||||
}
|
||||
|
||||
export interface DouyuRechargeChannel {
|
||||
gold_recharge_channel: 'wechat_qr' | 'supplier_api';
|
||||
gold_recharge_channel: "wechat_qr" | "supplier_api";
|
||||
}
|
||||
|
||||
export interface DouyuTaskBatchRequest {
|
||||
account_ids: number[];
|
||||
task_type: string;
|
||||
handbook_scope: 'elite' | 'esports' | 'peace';
|
||||
handbook_scope: "elite" | "esports" | "peace";
|
||||
concurrency?: number;
|
||||
payload?: Record<string, unknown>;
|
||||
}
|
||||
@@ -413,7 +428,7 @@ export interface DouyuTaskItem {
|
||||
account_uid: string;
|
||||
account_nickname: string;
|
||||
task_type: string;
|
||||
handbook_scope: 'elite' | 'esports' | 'peace' | 'legacy';
|
||||
handbook_scope: "elite" | "esports" | "peace" | "legacy";
|
||||
status: string;
|
||||
message: string;
|
||||
result: Record<string, unknown> | null;
|
||||
@@ -474,10 +489,10 @@ export interface HuyaFetchSmsCodeResult {
|
||||
message: string;
|
||||
}
|
||||
/** 工作台账号集合范围: elite=精英宝典 / browser_exchange=浏览器兑换 */
|
||||
export type HuyaWorkbenchScope = 'elite' | 'browser_exchange';
|
||||
export type HuyaWorkbenchScope = "elite" | "browser_exchange";
|
||||
|
||||
/** 浏览器兑换目标页: live_room=直播间 / elite=精英宝典 / esports=电竞宝典 */
|
||||
export type HuyaExchangeTargetKey = 'live_room' | 'elite' | 'esports';
|
||||
export type HuyaExchangeTargetKey = "live_room" | "elite" | "esports";
|
||||
|
||||
export interface HuyaExchangeTargetOption {
|
||||
key: HuyaExchangeTargetKey;
|
||||
@@ -592,7 +607,7 @@ export interface HuyaAutoRegisterRequest {
|
||||
|
||||
export interface HuyaAutoRegisterRetryRequest {
|
||||
/** continue=从停止处继续(默认,不重试失败);retry_failed=只重试失败;all_unfinished=失败+未完成 */
|
||||
mode?: 'continue' | 'retry_failed' | 'all_unfinished';
|
||||
mode?: "continue" | "retry_failed" | "all_unfinished";
|
||||
concurrency?: number;
|
||||
wait_seconds?: number;
|
||||
poll_interval?: number;
|
||||
@@ -720,7 +735,7 @@ export interface HuyaConfig {
|
||||
export interface HuyaTaskBatchRequest {
|
||||
account_ids: number[];
|
||||
task_type: string;
|
||||
handbook_scope?: 'legacy' | 'elite';
|
||||
handbook_scope?: "legacy" | "elite";
|
||||
concurrency?: number;
|
||||
payload?: Record<string, unknown>;
|
||||
}
|
||||
@@ -754,7 +769,7 @@ export interface HuyaTaskItem {
|
||||
account_uid: string;
|
||||
account_nickname: string;
|
||||
task_type: string;
|
||||
handbook_scope: 'legacy' | 'elite';
|
||||
handbook_scope: "legacy" | "elite";
|
||||
status: string;
|
||||
message: string;
|
||||
result: Record<string, unknown> | null;
|
||||
@@ -891,3 +906,23 @@ export interface AutomationRunOutcome {
|
||||
invalid: number;
|
||||
skipped: number;
|
||||
}
|
||||
|
||||
export interface AutomationManualSample {
|
||||
task_id: number;
|
||||
account_username: string;
|
||||
relogin_attempts: number;
|
||||
last_error: string;
|
||||
attempt_at: string | null;
|
||||
}
|
||||
|
||||
export interface AutomationManualGroup {
|
||||
kind: string;
|
||||
label: string;
|
||||
count: number;
|
||||
samples: AutomationManualSample[];
|
||||
}
|
||||
|
||||
export interface AutomationManualQueue {
|
||||
total: number;
|
||||
groups: AutomationManualGroup[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user