优化(账号自动化): 完善受保护账号重登筛选与登录配额分配
This commit is contained in:
@@ -12,6 +12,7 @@ from sqlalchemy.orm import Session
|
||||
from ..models import Account, LoginAttempt, LoginQuotaSetting
|
||||
from .account_lifecycle import MANUAL_KINDS, MANUAL_STATES
|
||||
from .account_protection_service import load_protection_snapshot
|
||||
from .account_query_filters import protected_relogin_eligible_filter
|
||||
from .account_value import is_high_value_expr
|
||||
|
||||
CK_AVERAGE_LIFETIME_DAYS = 7.38
|
||||
@@ -164,7 +165,19 @@ def recommend_login_budget(
|
||||
valid_query.filter(Account.id.in_(protected_ids)).count() or 0
|
||||
)
|
||||
protected_invalid = int(
|
||||
invalid_query.filter(Account.id.in_(protected_ids)).count() or 0
|
||||
db.query(func.count(Account.id))
|
||||
.filter(
|
||||
protected_relogin_eligible_filter(
|
||||
protected_ids=protected_ids,
|
||||
max_attempts=2,
|
||||
now=moment,
|
||||
cookie_operable=False,
|
||||
due_only=False,
|
||||
suppressed_ids=protection.suppressed_relogin_ids,
|
||||
)
|
||||
)
|
||||
.scalar()
|
||||
or 0
|
||||
)
|
||||
nonprotected_valid_high = int(
|
||||
_count_high_value(
|
||||
@@ -234,10 +247,8 @@ def recommend_login_budget(
|
||||
nonprotected_relogin_attempts - relogin_high_limit,
|
||||
)
|
||||
relogin_protected_limit = max(
|
||||
50,
|
||||
math.ceil(
|
||||
(protected_invalid / RELOGIN_RECOVERY_DAYS) / effective_rate
|
||||
),
|
||||
100,
|
||||
math.ceil((protected_invalid * 2) / effective_rate),
|
||||
)
|
||||
lease_refresh_limit = max(
|
||||
50,
|
||||
|
||||
Reference in New Issue
Block a user