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