perf(account-check): 优化账号检测首屏加载
This commit is contained in:
@@ -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