fix: reimport dict-cursor bug + add admin cleanup endpoint
Problem 1: Reimport fails completely (all exercises fail) Root cause: Line 465 existing[0] instead of existing['id'] Fix: Changed to existing['id'] for dict-cursor compatibility Problem 2: 221 exercises skipped, only 2 in database Root cause: Orphaned wiki_import_references from failed imports Fix: New admin endpoint to manually cleanup orphaned references New endpoints: - DELETE /api/import/mediawiki/admin/cleanup-orphaned-references Deletes all references where local_id doesn't exist in target table Returns count of deleted references per type - GET /api/import/mediawiki/admin/stats Shows references vs. actual count + orphaned count Helps diagnose import state issues Usage: 1. Call cleanup endpoint to remove orphaned references 2. Run normal import (reimport=false) 3. Should import all previously failed exercises
This commit is contained in:
1 parent
3a4160fd1c
commit
97a7fe7cba
3 files changed
+98
-2
No files matched your search
@@ -462,7 +462,7 @@ def _upsert_exercise(mapped: dict, reimport: bool) -> Optional[int]:
|
||||
equipment = _json.dumps(mapped.get("equipment", [])) if mapped.get("equipment") else None
|
||||
|
||||
if existing and reimport:
|
||||
ex_id = existing[0]
|
||||
ex_id = existing['id']
|
||||
cur.execute(
|
||||
"""UPDATE exercises SET
|
||||
title = %s, summary = %s, goal = %s, execution = %s,
|
||||
|
||||
Reference in new issue
Block a user