perf(fulfillment): 优化本地能力选号查询与索引

This commit is contained in:
yml
2026-11-23 17:18:39 +08:00
parent d5422b0ecd
commit f7a5979f9b
7 changed files with 225 additions and 11 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ TESTS_DIR = Path(__file__).resolve().parent
PROJECT_ROOT = TESTS_DIR.parent
VERSIONS_DIR = PROJECT_ROOT / "web" / "backend" / "migrations" / "versions"
HEAD_REVISION = "20261123_0122"
HEAD_REVISION = "20261123_0123"
# 迁移新增、但不声明在模型里的复合查询索引。
EXTRA_INDEXES = (
+29
View File
@@ -1153,6 +1153,35 @@ class TestSnapshotSync(_Base):
class TestAccountSelection(_Base):
def test_capability_candidate_query_selects_only_selection_columns(self):
query = account_selector._capability_candidate_query(
self.session,
commodity_id=COMMODITY,
required_points=1280,
now=NOW,
)
assert query is not None
selected = {
str(description["name"])
for description in query.column_descriptions
}
assert {
"account_id",
"account_username",
"account_points",
"account_elite_opened",
"state_offer_state",
"state_observed_at",
} <= selected
assert {
"account_cookie",
"account_overview_snapshot",
"account_ck_check_result",
"state_raw_json",
"state_schedule_json",
}.isdisjoint(selected)
def test_manual_allocation_request_only_marks_task_due(self):
task = self.task()
old_retry_at = task.next_allocate_at