feat(tools-pve/asr-pipeline): SQLite model config, task delete/rerefine, multi-recording review, lexicon CRUD
Build image / build (push) Canceled after 0s
Build ASR Pipeline / image (push) Canceled after 0s

This commit is contained in:
Codex
2026-11-01 23:14:31 -08:00
parent 2367c5eb4e
commit be589ff5e0
7 changed files with 2064 additions and 340 deletions
@@ -307,14 +307,14 @@ def _request_revision(draft_path: str) -> bool:
return False
def answer(question_id: int, value: str) -> dict:
def answer(question_id: int, value: str, *, allow_update: bool = False) -> dict:
con = lexicon.connect()
row = con.execute("SELECT * FROM review_question WHERE id=?",
(question_id,)).fetchone()
if not row:
con.close()
raise KeyError(f"review question {question_id} not found")
if row["status"] != "pending":
if row["status"] != "pending" and not allow_update:
result = {
"id": question_id, "answer": row["answer"], "learned": False,
"already_answered": True,
@@ -376,3 +376,47 @@ def answer(question_id: int, value: str) -> dict:
"draft_feedback_saved": saved, "voiceprint_enrolled": voiceprint_enrolled,
"revision_started": revision_started,
}
def recent_answered(limit: int = 30) -> list[dict]:
con = lexicon.connect()
rows = con.execute(
"SELECT * FROM review_question WHERE status='answered' "
"ORDER BY answered_at DESC, id DESC LIMIT ?",
(limit,),
).fetchall()
con.close()
return [dict(r) for r in rows]
def reopen_question(question_id: int) -> bool:
con = lexicon.connect()
cur = con.execute(
"UPDATE review_question SET status='pending', answer='', answered_at=NULL WHERE id=?",
(question_id,),
)
con.commit()
ok = cur.rowcount > 0
con.close()
return ok
def delete_for_job(transcript_path: str = "", draft_path: str = "", job_id: str = "") -> int:
con = lexicon.connect()
rows = con.execute("SELECT id, recording, payload FROM review_question").fetchall()
to_delete: list[int] = []
for r in rows:
payload = json.loads(r["payload"] or "{}")
if (
(transcript_path and r["recording"] == transcript_path)
or (draft_path and payload.get("draft_path") == draft_path)
or (job_id and payload.get("job_id") == job_id)
):
to_delete.append(int(r["id"]))
if to_delete:
marks = ",".join("?" for _ in to_delete)
con.execute(f"DELETE FROM review_question WHERE id IN ({marks})", to_delete)
con.commit()
con.close()
return len(to_delete)