feat: review durable Human Gate decision history (Closes #1441)
This commit is contained in:
1 parent
efa01cf47f
commit
a5d05d7590
22 files changed
+316
-34
No files matched your search
+14
-1
@@ -182,6 +182,12 @@ class HumanGateStore:
|
||||
"reason": row["decision_reason"], "override_reason": row["override_reason"],
|
||||
"checklist": json.loads(row["checklist_json"]),
|
||||
})
|
||||
receipt = connection.execute(
|
||||
"SELECT receipt_json FROM human_gate_receipts WHERE login=? AND gate_id=? ORDER BY rowid DESC LIMIT 1",
|
||||
(row["login"], row["id"]),
|
||||
).fetchone()
|
||||
if receipt:
|
||||
item["receipt_id"] = json.loads(receipt[0])["receipt_id"]
|
||||
if history:
|
||||
item["history"] = self._history(connection, row["id"])
|
||||
return item
|
||||
@@ -264,7 +270,14 @@ class HumanGateStore:
|
||||
with self._connect() as connection:
|
||||
pending_count = connection.execute("SELECT COUNT(*) FROM human_gates WHERE login=? AND state='pending'", (login,)).fetchone()[0]
|
||||
where, args = ("login=?", [login]) if state == "all" else ("login=? AND state=?", [login, state])
|
||||
rows = connection.execute(f"SELECT * FROM human_gates WHERE {where} ORDER BY CASE WHEN state='pending' THEN 0 ELSE 1 END, priority DESC, created_at, id LIMIT ?", (*args, limit)).fetchall()
|
||||
rows = connection.execute(
|
||||
f"SELECT * FROM human_gates WHERE {where} "
|
||||
"ORDER BY CASE WHEN state='pending' THEN 0 ELSE 1 END, "
|
||||
"CASE WHEN state='pending' THEN priority END DESC, "
|
||||
"CASE WHEN state='pending' THEN created_at END, "
|
||||
"CASE WHEN state!='pending' THEN updated_at END DESC, id LIMIT ?",
|
||||
(*args, limit),
|
||||
).fetchall()
|
||||
return {"pending_count": pending_count, "items": [self._present(connection, row) for row in rows]}
|
||||
|
||||
def detail(self, login: str, gate_id: str) -> dict:
|
||||
|
||||
Reference in new issue
Block a user