mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 10:27:46 +08:00
feat(oauth): 允许替换已失效的活跃 OAuth 账号并同步 status_snapshot
- 活跃但 token 已过期或刷新失败的重复账号视为可替换 - 清除失效标记、刷新配额时同步更新 status_snapshot.oauth - oauth_invalid 清除接口同时识别 invalid_at 与 invalid_reason 两种标记 - 批量导入任务状态区分 created_count / replaced_count,前端据此展示新增/替换统计 - 补充重复替换场景的集成测试,用量测试等待超时从 10s 提升到 30s 以适应并行压力
This commit is contained in:
@@ -251,6 +251,8 @@ pub(super) fn build_admin_provider_oauth_batch_task_state(
|
||||
processed: usize,
|
||||
success: usize,
|
||||
failed: usize,
|
||||
created_count: usize,
|
||||
replaced_count: usize,
|
||||
message: Option<&str>,
|
||||
error: Option<&str>,
|
||||
error_samples: Vec<serde_json::Value>,
|
||||
@@ -277,6 +279,8 @@ pub(super) fn build_admin_provider_oauth_batch_task_state(
|
||||
"processed": processed,
|
||||
"success": success,
|
||||
"failed": failed,
|
||||
"created_count": created_count,
|
||||
"replaced_count": replaced_count,
|
||||
"progress_percent": progress_percent,
|
||||
"message": message,
|
||||
"error": error,
|
||||
|
||||
@@ -95,6 +95,8 @@ pub(in super::super) async fn handle_admin_provider_oauth_start_batch_import_tas
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
Some("任务已提交,等待执行"),
|
||||
None,
|
||||
Vec::new(),
|
||||
@@ -134,6 +136,8 @@ pub(in super::super) async fn handle_admin_provider_oauth_start_batch_import_tas
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
Some("任务开始执行"),
|
||||
None,
|
||||
Vec::new(),
|
||||
@@ -169,6 +173,16 @@ pub(in super::super) async fn handle_admin_provider_oauth_start_batch_import_tas
|
||||
.take(PROVIDER_OAUTH_BATCH_TASK_MAX_ERROR_SAMPLES)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
let replaced_count = outcome
|
||||
.results
|
||||
.iter()
|
||||
.filter(|item| {
|
||||
item.get("status").and_then(serde_json::Value::as_str) == Some("success")
|
||||
&& item.get("replaced").and_then(serde_json::Value::as_bool)
|
||||
== Some(true)
|
||||
})
|
||||
.count();
|
||||
let created_count = outcome.success.saturating_sub(replaced_count);
|
||||
let message = format!(
|
||||
"导入完成:成功 {},失败 {}",
|
||||
outcome.success, outcome.failed
|
||||
@@ -182,6 +196,8 @@ pub(in super::super) async fn handle_admin_provider_oauth_start_batch_import_tas
|
||||
outcome.total,
|
||||
outcome.success,
|
||||
outcome.failed,
|
||||
created_count,
|
||||
replaced_count,
|
||||
Some(message.as_str()),
|
||||
None,
|
||||
error_samples,
|
||||
@@ -209,6 +225,8 @@ pub(in super::super) async fn handle_admin_provider_oauth_start_batch_import_tas
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
Some("导入任务执行失败"),
|
||||
Some(error_message.as_str()),
|
||||
Vec::new(),
|
||||
@@ -238,6 +256,8 @@ pub(in super::super) async fn handle_admin_provider_oauth_start_batch_import_tas
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
Some("任务已提交,等待执行"),
|
||||
None,
|
||||
Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user