Fixes on logging

This commit is contained in:
2026-04-20 16:53:12 +02:00
parent 372d8e01d0
commit 8f14b86e68
3 changed files with 48 additions and 5 deletions
+38
View File
@@ -723,6 +723,24 @@ async def conflicts(request: Request) -> dict:
return {"conflicts": [format_row(r) for r in rows]}
@app.post("/conflicts/clear")
async def clear_conflicts(request: Request) -> dict:
"""
Delete all pending conflicts from the resolution queue and clear the
in-memory pending set. Resolved/error rows are left untouched.
"""
pool = request.app.state.pool
async with pool.acquire() as conn:
result = await conn.execute(
"DELETE FROM resolution_queue WHERE status = 'pending'"
)
# result is a string like "DELETE 17"
deleted = int(result.split()[-1]) if result else 0
cache.pending_conflicts.clear()
log.info("conflicts cleared deleted=%d", deleted)
return {"status": "ok", "deleted": deleted}
@app.get("/kg-log")
async def kg_log(request: Request, limit: int = 100, offset: int = 0, op: str = "") -> dict:
"""Return recent knowledge graph write log entries, newest first."""
@@ -1491,6 +1509,9 @@ ADMIN_HTML = """<!DOCTYPE html>
<pre id="result" style="display:none"></pre>
<h2>Pending conflicts</h2>
<div class="actions" style="margin-bottom:0.5em">
<button onclick="clearConflicts(this)">Clear pending conflicts</button>
</div>
<pre id="conflicts-pre">Loading…</pre>
<h2>Knowledge graph write log</h2>
@@ -1549,6 +1570,23 @@ ADMIN_HTML = """<!DOCTYPE html>
el.textContent = text;
}}
async function clearConflicts(btn) {{
if (!confirm('Delete all pending conflicts from the resolution queue?')) return;
btn.disabled = true;
showResult('Clearing pending conflicts…', true);
try {{
const r = await fetch('/conflicts/clear', {{method: 'POST'}});
const d = await r.json();
showResult(JSON.stringify(d, null, 2), r.ok);
await loadStats();
await loadConflicts();
}} catch(e) {{
showResult('Error: ' + e.message, false);
}} finally {{
btn.disabled = false;
}}
}}
async function runResolution(btn) {{
btn.disabled = true;
showResult('Running resolution job…', true);