Spaces:
Sleeping
Sleeping
Adzacam commited on
Commit 路
cc5c869
1
Parent(s): 5550b89
Diag: Endpoint /api/v1/diagnostico para trazabilidad de tablas en Supabase
Browse files
app.py
CHANGED
|
@@ -47,6 +47,37 @@ def read_root():
|
|
| 47 |
"ner_initialized": ner_engine._initialized or ner_engine.pipeline is not None
|
| 48 |
}
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
@app.post("/api/v1/ingesta/tabular", status_code=status.HTTP_201_CREATED)
|
| 51 |
def procesar_registro_tabular(payload: ProcessSheetPayload, db: Session = Depends(get_db)):
|
| 52 |
try:
|
|
|
|
| 47 |
"ner_initialized": ner_engine._initialized or ner_engine.pipeline is not None
|
| 48 |
}
|
| 49 |
|
| 50 |
+
@app.get("/api/v1/diagnostico")
|
| 51 |
+
def diagnostico_db(db: Session = Depends(get_db)):
|
| 52 |
+
"""
|
| 53 |
+
Endpoint de diagn贸stico: prueba cada tabla individualmente y reporta
|
| 54 |
+
el error exacto de PostgreSQL. 脷til para detectar RLS, tablas inexistentes
|
| 55 |
+
o columnas incorrectas sin tocar el c贸digo de producci贸n.
|
| 56 |
+
"""
|
| 57 |
+
resultados = {}
|
| 58 |
+
tablas = {
|
| 59 |
+
"dim_estudiante": DimEstudiante,
|
| 60 |
+
"dim_docente": DimDocente,
|
| 61 |
+
"dim_modulo": DimModulo,
|
| 62 |
+
"dim_tiempo": DimTiempo,
|
| 63 |
+
"dim_origen_documental": DimOrigenDocumental,
|
| 64 |
+
"users": Users,
|
| 65 |
+
"fact_rendimiento_academico": FactRendimientoAcademico,
|
| 66 |
+
}
|
| 67 |
+
for nombre, modelo in tablas.items():
|
| 68 |
+
try:
|
| 69 |
+
count = db.query(modelo).count()
|
| 70 |
+
resultados[nombre] = {"ok": True, "count": count}
|
| 71 |
+
except Exception as e:
|
| 72 |
+
resultados[nombre] = {"ok": False, "error": str(e)}
|
| 73 |
+
|
| 74 |
+
todo_ok = all(v["ok"] for v in resultados.values())
|
| 75 |
+
return {
|
| 76 |
+
"conexion": "ok",
|
| 77 |
+
"tablas": resultados,
|
| 78 |
+
"listo_para_produccion": todo_ok
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
@app.post("/api/v1/ingesta/tabular", status_code=status.HTTP_201_CREATED)
|
| 82 |
def procesar_registro_tabular(payload: ProcessSheetPayload, db: Session = Depends(get_db)):
|
| 83 |
try:
|