From 6232f25cc9f9225b7580750bfe97fc47da47b163 Mon Sep 17 00:00:00 2001 From: Otto Date: Wed, 27 May 2026 18:36:03 +0200 Subject: [PATCH] fix(fastapi): remove duplicate confirm/reject routes - api_confirm and api_reject were defined twice on same paths - FastAPI only registers first definition, causing silent 404s - Kept api_confirm_engram and api_reject_engram (use _update_correctness) - Removed duplicate direct DB implementations - Fixes dashboard confirm/reject buttons not working --- fastapi_app.py | 66 -------------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/fastapi_app.py b/fastapi_app.py index cc22b21..098714e 100644 --- a/fastapi_app.py +++ b/fastapi_app.py @@ -690,72 +690,6 @@ def api_refresh_engram(engram_id: str): return JSONResponse({"error": str(e)}, status_code=404) -@app.post("/api/engrams/{engram_id}/confirm") -def api_confirm(engram_id: str, reason: str = Form("")): - conn = get_db() - c = conn.cursor() - row = c.execute( - "SELECT correctness_json FROM engrams WHERE id = ?", (engram_id,) - ).fetchone() - if not row: - conn.close() - return JSONResponse({"error": "Not found"}, status_code=404) - - correctness = json.loads(row["correctness_json"] or "{}") - correctness["confirmed"] = True - correctness["confirmations"] = correctness.get("confirmations", 0) + 1 - correctness["last_reviewed"] = datetime.now(timezone.utc).isoformat() - review_history = correctness.get("review_history", []) - review_history.append({ - "by": "web", - "action": "confirm", - "at": datetime.now(timezone.utc).isoformat(), - "note": reason or "confirmed via dashboard", - }) - correctness["review_history"] = review_history - - c.execute( - "UPDATE engrams SET correctness_json = ?, modified_at = ? WHERE id = ?", - (json.dumps(correctness), datetime.now(timezone.utc).isoformat(), engram_id), - ) - conn.commit() - conn.close() - return {"success": True, "engram_id": engram_id} - - -@app.post("/api/engrams/{engram_id}/reject") -def api_reject(engram_id: str, reason: str = Form("")): - conn = get_db() - c = conn.cursor() - row = c.execute( - "SELECT correctness_json FROM engrams WHERE id = ?", (engram_id,) - ).fetchone() - if not row: - conn.close() - return JSONResponse({"error": "Not found"}, status_code=404) - - correctness = json.loads(row["correctness_json"] or "{}") - correctness["confirmed"] = False - correctness["rejections"] = correctness.get("rejections", 0) + 1 - correctness["last_reviewed"] = datetime.now(timezone.utc).isoformat() - review_history = correctness.get("review_history", []) - review_history.append({ - "by": "web", - "action": "reject", - "at": datetime.now(timezone.utc).isoformat(), - "note": reason or "rejected via dashboard", - }) - correctness["review_history"] = review_history - - c.execute( - "UPDATE engrams SET correctness_json = ?, modified_at = ? WHERE id = ?", - (json.dumps(correctness), datetime.now(timezone.utc).isoformat(), engram_id), - ) - conn.commit() - conn.close() - return {"success": True, "engram_id": engram_id} - - @app.post("/api/engrams/{engram_id}/refresh") def api_refresh(engram_id: str): conn = get_db()