[PRISM] Add prepared rerun plan API
lint / hygiene (push) Failing after 33s
standard / check (push) Successful in 12s

This commit is contained in:
root committed 2026-11-24 11:47:37 +03:00
1 parent 520976a487
commit b9f54904a4
1 file changed
+24
+24
View File
@@ -1732,6 +1732,28 @@ def _prism_sql(sql):
return json.loads(out.strip())
def prism_rerun():
try:
sql = (
"select json_build_object("
"'batch1',(select count(*) from prism.rerun_plan where batch=1 and state='prepared'),"
"'batch2',(select count(*) from prism.rerun_plan where batch=2 and state='prepared'),"
"'excluded',(select count(*) from prism.rerun_plan where state='excluded'),"
"'first',(select coalesce(json_agg(row_to_json(t)),'[]'::json) from ("
"select m.id,m.vendor,m.name,m.quality_status,m.review_status,"
"(select count(*) from prism.specs sp where sp.model_id=m.id) as specs,"
"(select count(*) from prism.model_notes n where n.model_id=m.id) as notes,"
"(select count(*) from prism.note_audits a where a.model_id=m.id) as audits "
"from prism.rerun_plan p join prism.models m on m.id=p.model_id "
"where p.batch=1 and p.state='prepared' order by m.vendor,m.name) t)"
")::text"
)
return _prism_sql(sql)
except Exception as e:
return {"ok": False, "error": str(e)[:200]}
def prism_search(query, limit=50):
try:
q = str(query or "").strip()
@@ -1797,6 +1819,8 @@ class H(BaseHTTPRequestHandler):
return self._out(open(f, encoding="utf-8").read().encode(), ctype="text/html; charset=utf-8")
if p in ("/health", "/api/health"):
return self._out({"ok": True, "service": "combine-web", "devices": len(D.devices)})
if p == "/api/prism/rerun":
return self._out(prism_rerun())
if p == "/api/prism/search":
return self._out(prism_search(q.get("q", [""])[0], q.get("limit", ["50"])[0]))
if p == "/api/prism/llm":