功能:增加旧测试数据闭包纳入

This commit is contained in:
焦龙言
2026-09-23 13:15:59 +08:00
parent c97f6ed3bd
commit 91cf862248
5 changed files with 1009 additions and 3 deletions
@@ -149,8 +149,39 @@ class TestBatchDao:
async def count_owned_rows(cls, db: AsyncSession, batch_id: int) -> dict[str, int]:
counts: dict[str, int] = {}
for model in _BATCH_OWNED_MODELS:
result = await db.execute(
select(func.count()).select_from(model).where(model.test_batch_id == batch_id)
)
result = await db.execute(select(func.count()).select_from(model).where(model.test_batch_id == batch_id))
counts[model.__tablename__] = result.scalar() or 0
return counts
@classmethod
async def store_preview(
cls,
db: AsyncSession,
batch: BizTestBatch,
*,
action: str,
token_hash: str,
scope_hash: str,
expires_at: datetime,
update_by: str,
update_time: datetime,
) -> None:
"""在已锁定的批次对象上保存一次性预览状态。"""
batch.preview_action = action
batch.preview_token_hash = token_hash
batch.preview_scope_hash = scope_hash
batch.preview_expires_at = expires_at
batch.update_by = update_by
batch.update_time = update_time
@classmethod
async def clear_preview(
cls,
db: AsyncSession,
batch: BizTestBatch,
) -> None:
"""消费已锁定批次上的预览令牌与范围摘要。"""
batch.preview_action = None
batch.preview_token_hash = None
batch.preview_scope_hash = None
batch.preview_expires_at = None