feat(account-check): 增加履约账号 CK 保护目标
This commit is contained in:
@@ -18,6 +18,7 @@ from ..models import (
|
||||
LoginAttempt,
|
||||
)
|
||||
from .account_capability_service import AVAILABILITY_AVAILABLE, AVAILABILITY_LIMITED
|
||||
from .account_protection_service import evaluate_protection_targets
|
||||
from .account_supply_service import evaluate_supply_targets
|
||||
|
||||
TREND_DAYS = 7
|
||||
@@ -367,6 +368,42 @@ def account_platform_status(
|
||||
}
|
||||
)
|
||||
|
||||
protection_targets = evaluate_protection_targets(db, now=moment)
|
||||
for item in protection_targets:
|
||||
if not item["enabled"]:
|
||||
continue
|
||||
affected = (
|
||||
int(item["ck_invalid"])
|
||||
+ int(item["ck_error"])
|
||||
+ int(item["without_cookie"])
|
||||
)
|
||||
if affected:
|
||||
alerts.append(
|
||||
{
|
||||
"code": "account_protection_ck_affected",
|
||||
"severity": "critical",
|
||||
"group_key": item["group_key"],
|
||||
"count": affected,
|
||||
"message": (
|
||||
f"{item['label']}有 {affected} 个账号 CK 失效、"
|
||||
"检测异常或缺少 CK"
|
||||
),
|
||||
}
|
||||
)
|
||||
if int(item["target_shortage"]) > 0:
|
||||
alerts.append(
|
||||
{
|
||||
"code": "account_protection_target_shortage",
|
||||
"severity": "warning",
|
||||
"group_key": item["group_key"],
|
||||
"count": int(item["target_shortage"]),
|
||||
"message": (
|
||||
f"{item['label']}有效 CK 距目标还差 "
|
||||
f"{item['target_shortage']} 个"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
if not inventories:
|
||||
alerts.append(
|
||||
{
|
||||
@@ -479,6 +516,7 @@ def account_platform_status(
|
||||
"fresh_available": fresh_available,
|
||||
"fresh_limited": fresh_limited,
|
||||
},
|
||||
"protection_targets": protection_targets,
|
||||
"supply_targets": supply_targets,
|
||||
"alerts": alerts,
|
||||
"trends": trends,
|
||||
|
||||
Reference in New Issue
Block a user