[PRISM] Add final card API for first 6 models
This commit is contained in:
1 parent
23cc549199
commit
3022d00649
1 file changed
+20
@@ -1734,6 +1734,24 @@ def _prism_sql(sql):
|
||||
|
||||
|
||||
|
||||
|
||||
def prism_final_cards():
|
||||
try:
|
||||
sql = (
|
||||
"select coalesce(json_agg(row_to_json(t)),'[]'::json)::text from ("
|
||||
"select m.vendor,m.name,m.role,m.domain,f.state,"
|
||||
"jsonb_array_length(f.card->'specs') as specs,"
|
||||
"jsonb_array_length(f.card->'notes') as notes,"
|
||||
"(f.card->'audit'->>'ok') as audit_ok,"
|
||||
"f.card->'audit'->'issues' as audit_issues "
|
||||
"from prism.final_cards f join prism.models m on m.id=f.model_id "
|
||||
"order by m.vendor,m.name) t"
|
||||
)
|
||||
return _prism_sql(sql)
|
||||
except Exception as e:
|
||||
return {"ok": False, "error": str(e)[:200]}
|
||||
|
||||
|
||||
def prism_cards(only=None):
|
||||
try:
|
||||
cond = ""
|
||||
@@ -1852,6 +1870,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/final-cards":
|
||||
return self._out(prism_final_cards())
|
||||
if p == "/api/prism/cards":
|
||||
return self._out(prism_cards(q.get("batch", [""])[0]))
|
||||
if p == "/api/prism/rerun":
|
||||
|
||||
Reference in new issue
Block a user