Actualizar backend/main.py
This commit is contained in:
@@ -52,22 +52,32 @@ def cache_estadisticas():
|
||||
def cache_refresh():
|
||||
services.refrescar_todo()
|
||||
return {"status": "refrescado"}
|
||||
|
||||
|
||||
@app.post("/api/cache/refresh-manual")
|
||||
def cache_refresh_manual(clave: str = None):
|
||||
"""Botón 'Actualizar': re-lee las bases para la vista actual (clave) al instante,
|
||||
y recachea el resto en segundo plano."""
|
||||
return services.refrescar_manual(clave)
|
||||
|
||||
|
||||
@app.get("/api/ultima-actualizacion")
|
||||
def api_ultima_actualizacion():
|
||||
return services.ultima_actualizacion()
|
||||
|
||||
|
||||
@app.post("/api/precarga/modulo")
|
||||
def api_precarga_modulo(modulo: str, ano: int):
|
||||
"""Calienta en 2º plano la tabla principal del módulo para el año indicado."""
|
||||
return services.precargar_modulo(modulo, ano)
|
||||
|
||||
|
||||
@app.get("/api/precarga/estado")
|
||||
def api_precarga_estado(modulo: str):
|
||||
"""Progreso de la precarga."""
|
||||
"""Progreso de la precarga (para el aviso 'ya cargó todo')."""
|
||||
return services.precarga_estado(modulo)
|
||||
|
||||
|
||||
@app.get("/api/periodo-actual")
|
||||
def periodo_actual():
|
||||
dm = services.get_dm()
|
||||
@@ -99,9 +109,10 @@ def get_ocupabilidad_alumnos(num_indice: str = Query(...)):
|
||||
# ── VENTAS ─────────────────────────────────────────────────────────────────
|
||||
@app.get("/api/ventas")
|
||||
def get_ventas(ano: int = Query(...), mes: int = Query(...),
|
||||
sede: str = Query("TODOS"), programa: str = Query("TODOS")):
|
||||
sede: str = Query("TODOS"), programa: str = Query("TODOS"),
|
||||
con_overrides: bool = Query(False)):
|
||||
try:
|
||||
return services.ventas(ano, mes, sede, programa)
|
||||
return services.ventas(ano, mes, sede, programa, con_overrides)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@@ -128,9 +139,12 @@ def get_cobranza(
|
||||
mes: int = Query(...),
|
||||
sectorista: str = Query("TODOS"),
|
||||
agrupacion: str = Query("SEDE"),
|
||||
sede_filtro: str = Query("TODOS"),
|
||||
prog_filtro: str = Query("TODOS"),
|
||||
venc_hasta: str = Query("TODOS"),
|
||||
):
|
||||
try:
|
||||
return services.cobranza(ano, mes, sectorista, agrupacion)
|
||||
return services.cobranza(ano, mes, sectorista, agrupacion, sede_filtro, prog_filtro, venc_hasta)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@@ -142,9 +156,12 @@ def get_cobranza_detalle(
|
||||
mes: int = Query(...),
|
||||
sectorista: str = Query("TODOS"),
|
||||
agrupacion: str = Query("PROGRAMA"),
|
||||
prog_filtro: str = Query("TODOS"),
|
||||
sede_filtro: str = Query("TODOS"),
|
||||
venc_hasta: str = Query("TODOS"),
|
||||
):
|
||||
try:
|
||||
return services.cobranza_detalle(grupo, ano, mes, sectorista, agrupacion)
|
||||
return services.cobranza_detalle(grupo, ano, mes, sectorista, agrupacion, prog_filtro, sede_filtro, venc_hasta)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@@ -223,6 +240,15 @@ def post_clasificar_sede(payload: dict = Body(...)):
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.post("/api/cobranza/clasificar-full")
|
||||
def post_clasificar_full(payload: dict = Body(...)):
|
||||
"""Devuelve {programa: {sede, filtro}} usando el JSON REPLACE_META."""
|
||||
try:
|
||||
nombres = payload.get("programas", [])
|
||||
return {"mapa": services.clasificar_programas_full(nombres)}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@app.get("/api/debug/supabase-inicios")
|
||||
def debug_supabase_inicios(ano: int, mes: int):
|
||||
@@ -276,7 +302,7 @@ def get_cobranza_detalle_todos(ano: int, mes: int, sectorista: str = "TODOS"):
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
# ── ESTADO / OBSERVACIONES POR ALUMNO (Cobranza) ───────────────────────────
|
||||
# ── USUARIOS ───────────────────────────────────────────────────────────────
|
||||
@app.get("/api/alumno/estado")
|
||||
def get_alumno_estado(matricula: str):
|
||||
try:
|
||||
@@ -284,6 +310,13 @@ def get_alumno_estado(matricula: str):
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.get("/api/alumnos/por-retirar")
|
||||
def get_alumnos_por_retirar():
|
||||
try:
|
||||
return services.alumnos_por_retirar()
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.post("/api/alumno/estado/guardar")
|
||||
def post_alumno_estado(payload: dict = Body(...)):
|
||||
try:
|
||||
@@ -295,14 +328,6 @@ def post_alumno_estado(payload: dict = Body(...)):
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.get("/api/alumnos/por-retirar")
|
||||
def get_alumnos_por_retirar():
|
||||
try:
|
||||
return services.alumnos_por_retirar()
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
# ── USUARIOS ───────────────────────────────────────────────────────────────
|
||||
@app.get("/api/usuarios")
|
||||
def get_usuarios():
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user