perf(account-check): 优化账号检测首屏加载
This commit is contained in:
@@ -161,6 +161,22 @@ def test_protection_target_reports_ck_health_and_shortage(db):
|
||||
}
|
||||
|
||||
|
||||
def test_protection_target_counts_missing_cookie_without_full_account_load(db):
|
||||
account = _account("protection-no-cookie")
|
||||
account.cookie = ""
|
||||
db.add(account)
|
||||
db.flush()
|
||||
db.add(_presale_task(account))
|
||||
db.add(_health_job())
|
||||
db.commit()
|
||||
|
||||
rows = evaluate_protection_targets(db, now=NOW)
|
||||
presale = next(row for row in rows if row["group_key"] == "presale_bound")
|
||||
|
||||
assert presale["bound_count"] == 1
|
||||
assert presale["without_cookie"] == 1
|
||||
|
||||
|
||||
def test_ck_health_probes_protected_account_at_its_shorter_interval_first(db):
|
||||
protected = _account(
|
||||
"protection-due",
|
||||
|
||||
@@ -19,9 +19,16 @@ from web.backend.models import (
|
||||
LoginAttempt,
|
||||
User,
|
||||
)
|
||||
from web.backend.routers.douyu import create_supply_target, list_supply_targets
|
||||
from web.backend.routers.douyu import (
|
||||
create_supply_target,
|
||||
list_supply_target_configs,
|
||||
list_supply_targets,
|
||||
)
|
||||
from web.backend.schemas import DouyuSupplyTargetUpsert
|
||||
from web.backend.services.account_observability import account_platform_status
|
||||
from web.backend.services.account_observability import (
|
||||
account_platform_status,
|
||||
account_platform_trends,
|
||||
)
|
||||
from web.backend.services.account_supply_service import (
|
||||
VALUE_HIGH,
|
||||
_global_inventory_totals,
|
||||
@@ -349,6 +356,9 @@ def test_supply_target_configuration_route_returns_inventory(db):
|
||||
assert listed[0].id == created.id
|
||||
assert listed[0].target_id == created.id
|
||||
assert listed[0].needs_replenishment is True
|
||||
configs = list_supply_target_configs(db=db, current=user)
|
||||
assert configs[0].target_id == created.target_id
|
||||
assert configs[0].target_covered == 10
|
||||
|
||||
|
||||
def test_account_platform_status_aggregates_queue_sync_and_supply(db):
|
||||
@@ -400,6 +410,21 @@ def test_account_platform_status_aggregates_queue_sync_and_supply(db):
|
||||
}
|
||||
|
||||
|
||||
def test_account_platform_status_can_defer_trends(db):
|
||||
account = _account("platform-no-trends", points=400)
|
||||
db.add(account)
|
||||
db.flush()
|
||||
db.add(_state(account))
|
||||
db.commit()
|
||||
|
||||
status = account_platform_status(db, now=NOW, include_trends=False)
|
||||
trends = account_platform_trends(db, now=NOW)
|
||||
|
||||
assert status["trends"] is None
|
||||
assert len(trends["trends"]["query"]) == 7
|
||||
assert isinstance(trends["alerts"], list)
|
||||
|
||||
|
||||
def test_account_platform_status_builds_seven_day_trends(db):
|
||||
account = _account("platform-trends", points=400)
|
||||
db.add(account)
|
||||
|
||||
Reference in New Issue
Block a user