update
This commit is contained in:
@@ -1186,6 +1186,23 @@ async def default_subblock_levels(topic: str, block_norm: str) -> None:
|
||||
await db.commit()
|
||||
|
||||
|
||||
async def delete_stale_consensus(topic: str, block_norm: str, keep: set[str]) -> None:
|
||||
"""Drop consensus rows of a block that are NOT in this run's sidecar (`keep`): finalize
|
||||
only upserts, so re-runs piled up orphan rows (measured: 25 subs without any board-2
|
||||
output). variant/discarded rows stay — QA reads those statuses."""
|
||||
db = await get_db()
|
||||
cursor = await db.execute(
|
||||
"SELECT sub_norm FROM subblocks WHERE topic = ? AND block_norm = ? AND status = 'consensus'",
|
||||
(topic, block_norm))
|
||||
rows = await cursor.fetchall()
|
||||
stale = [r[0] for r in rows if r[0] not in keep]
|
||||
for sn in stale:
|
||||
await db.execute("DELETE FROM subblocks WHERE topic = ? AND block_norm = ? AND sub_norm = ?",
|
||||
(topic, block_norm, sn))
|
||||
if stale:
|
||||
await db.commit()
|
||||
|
||||
|
||||
async def set_subblock_fields(topic: str, block_norm: str, sub_norm: str, **fields) -> None:
|
||||
"""Set fields (level/relevance/status/sub_title) of a subblock row."""
|
||||
fields["updated_at"] = _now()
|
||||
|
||||
Reference in New Issue
Block a user