发布(0.4.1): 优化分配性能与客服数据边界

修复分配页皮肤查询并发慢查询;客服导入账号严格限制为本人名下;分配概览改用真实归属数量;标题区展示版本并提示刷新。
This commit is contained in:
yml
2026-11-26 21:19:11 +08:00
parent 174ae23ac1
commit 7dfc9d725e
15 changed files with 409 additions and 106 deletions
+28 -5
View File
@@ -113,6 +113,25 @@ class TestAssignFilter(_Base):
assert self.names(assigned_user_id=self.other.id) == ["a-of-kf2"]
def test_support_with_view_all_permission_still_only_sees_owned_accounts(self):
own = self.make_account("a-support-own", assigned_to=self.support.id)
self.make_account("a-support-other", assigned_to=self.other.id)
self.support.custom_permissions = [
"account:view_assigned",
"account:view_all",
]
self.session.commit()
result = list_accounts(
page=1,
page_size=50,
include_sensitive=False,
db=self.session,
current=self.support,
)
assert [item.id for item in result["items"]] == [own.id]
def test_combines_with_tag(self):
"""综合筛选:归属 + 标签要**同时**生效,而不是后一个覆盖前一个。"""
self.make_account("tag-a-free", tag="10.1-测试")
@@ -142,7 +161,7 @@ class TestAssignablePool(_Base):
"ap-valid",
]
def test_summary_counts_only_assignable(self):
def test_summary_counts_actual_assignment_not_only_fresh_ck(self):
self.make_account("as-valid", ck_check_status="valid")
self.make_account("as-invalid", ck_check_status="invalid")
self.make_account(
@@ -156,13 +175,14 @@ class TestAssignablePool(_Base):
summary = assignments_summary(db=self.session, current=self.admin)
assert summary["unassigned_count"] == 1
assert summary["assigned_count"] == 1
assert summary["total_count"] == 2
assert summary["unassigned_count"] == 2
assert summary["assigned_count"] == 2
assert summary["orphaned_count"] == 0
assert summary["total_count"] == 4
support = next(
u for u in summary["support_users"] if u["id"] == self.support.id
)
assert support["assigned_count"] == 1
assert support["assigned_count"] == 2
def test_all_matching_assignable_only_skips_invalid(self):
valid = self.make_account("am-valid", ck_check_status="valid")
@@ -346,12 +366,15 @@ class TestAssignmentPools(_Base):
)
self.session.add(inactive)
self.session.commit()
self.make_account("inactive-support-account", assigned_to=inactive.id)
result = assignments_summary(db=self.session, current=self.admin)
support_ids = {user["id"] for user in result["support_users"]}
assert self.support.id in support_ids
assert inactive.id not in support_ids
assert result["orphaned_count"] == 1
assert result["assigned_count"] == 0
def test_dispatch_rejects_inactive_support(self):
inactive = User(
+14
View File
@@ -0,0 +1,14 @@
"""应用版本与前端构建标识。"""
from web.backend.version import get_app_version, get_frontend_release_id
def test_frontend_release_id_combines_version_and_build_digest():
get_frontend_release_id.cache_clear()
version = get_app_version()
release_id = get_frontend_release_id()
assert release_id.startswith(f"{version}+")
digest = release_id.split("+", 1)[1]
assert digest == "source" or len(digest) == 12
+34
View File
@@ -10,6 +10,8 @@ from web.backend.models import Account, DouyuTask, DouyuWorkbenchAccount, User
from web.backend.routers.douyu import (
_split_task_scope_query,
_visible_tasks_query,
list_task_account_ids,
list_task_accounts,
list_tasks,
)
from web.backend.services.douyu_service import (
@@ -372,6 +374,38 @@ def test_workbench_task_list_is_limited_to_selected_accounts(db):
}
def test_support_with_view_all_permission_still_only_sees_own_import_pool(db):
support, _, _, _, tasks = _seed_tasks(db)
support.custom_permissions = [
"douyu:task",
"account:view_assigned",
"account:view_all",
]
db.commit()
expected_account_id = tasks["assigned_elite"].account_id
rows = list_task_accounts(
search="",
tag="",
ids="",
account_names="",
page=None,
page_size=100,
db=db,
current=support,
)
ids = list_task_account_ids(
search="",
tag="",
account_names="",
db=db,
current=support,
)
assert [row.id for row in rows] == [expected_account_id]
assert ids["account_ids"] == [expected_account_id]
def test_empty_support_task_list_stays_empty(db):
support = User(
username="empty-task-support",