修复登录任务页面加载慢的问题
- 后端: list_tasks 用 IN 批量查 Account 替代逐条查询,消除 N+1 - 后端: list_accounts 用 joinedload 预加载 assigned_user,消除懒加载 - 前端: 首次加载 accounts 和 tasks 并行请求 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
a996028f5b
commit
accb76b9da
@@ -11,6 +11,7 @@ from ..schemas import AccountImport, AccountAssign, AccountTag, AccountOut, Batc
|
||||
from ..deps import get_current_user, require_permission
|
||||
from ..permissions import has_permission
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
router = APIRouter(prefix="/api/accounts", tags=["账号管理"])
|
||||
|
||||
@@ -64,7 +65,7 @@ def list_accounts(
|
||||
if tag:
|
||||
query = query.filter(Account.tag == tag)
|
||||
|
||||
accounts = query.order_by(Account.id).all()
|
||||
accounts = query.order_by(Account.id).options(joinedload(Account.assigned_user)).all()
|
||||
result = []
|
||||
for acc in accounts:
|
||||
item = AccountOut(
|
||||
|
||||
Reference in New Issue
Block a user