fix(import+screening): GET-Alias, DELETE-Endpoint, ehrlicher Scan-Status
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 37s
CI / test-python-backend-compliance (push) Successful in 32s
CI / test-python-dsms-gateway (push) Has been cancelled
CI / test-python-document-crawler (push) Has been cancelled

Import-Backend:
- GET /v1/import (Root-Alias) → list_documents; behebt URL-Mismatch im Proxy
- DELETE /v1/import/{document_id} → löscht Dokument + Gap-Analyse (mit Tenant-Isolierung)
- 6 neue Tests (65 total, alle grün)

Screening-Frontend:
- Simulierten Fortschrittsbalken (Math.random) entfernt — war inhaltlich falsch
- Ersetzt durch indeterminate Spinner + rotierende ehrliche Status-Texte
  (z.B. "OSV.dev Datenbank wird abgefragt...") im 2-Sek.-Takt
- Kein scanProgress-State mehr benötigt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-05 12:07:01 +01:00
parent 3707ffe799
commit ef17151a41
3 changed files with 175 additions and 50 deletions

View File

@@ -400,3 +400,46 @@ async def list_documents(tenant_id: str = "default"):
return DocumentListResponse(documents=documents, total=len(documents))
finally:
db.close()
@router.get("", response_model=DocumentListResponse)
async def list_documents_root(
tenant_id: str = "default",
x_tenant_id: Optional[str] = Header(None, alias="X-Tenant-ID"),
):
"""Alias: GET /v1/import → list documents (proxy-compatible URL)."""
tid = x_tenant_id or tenant_id
return await list_documents(tenant_id=tid)
@router.delete("/{document_id}")
async def delete_document(
document_id: str,
tenant_id: str = "default",
x_tenant_id: Optional[str] = Header(None, alias="X-Tenant-ID"),
):
"""Delete an imported document and its gap analysis."""
tid = x_tenant_id or tenant_id
db = SessionLocal()
try:
# Delete gap analysis first (FK dependency)
db.execute(
"DELETE FROM compliance_gap_analyses WHERE document_id = :doc_id AND tenant_id = :tid",
{"doc_id": document_id, "tid": tid},
)
result = db.execute(
"DELETE FROM compliance_imported_documents WHERE id = :doc_id AND tenant_id = :tid",
{"doc_id": document_id, "tid": tid},
)
db.commit()
if result.rowcount == 0:
raise HTTPException(status_code=404, detail="Document not found")
return {"success": True, "deleted_id": document_id}
except HTTPException:
raise
except Exception as e:
db.rollback()
logger.error(f"Failed to delete document {document_id}: {e}")
raise HTTPException(status_code=500, detail="Failed to delete document")
finally:
db.close()