功能:增加旧测试数据闭包纳入
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user