fix: fallback de credenciales DB y parseo seguro de parametros

This commit is contained in:
desoladorxx
2026-07-22 17:35:14 -05:00
parent db1ad00c5d
commit cb568bc697
6 changed files with 55 additions and 20 deletions

View File

@@ -47,11 +47,14 @@ def _en_periodo(d, ano, mes, dia):
"""True si la fecha cae en el filtro (ano/mes/dia; 'TODOS' = sin filtrar)."""
if d is None:
return False
if ano not in ("TODOS", None) and d.year != int(ano):
return False
if mes not in ("TODOS", None) and d.month != int(mes):
return False
if dia not in ("TODOS", None) and d.day != int(dia):
try:
if ano not in ("TODOS", None, "") and str(ano).upper() != "TODOS" and d.year != int(ano):
return False
if mes not in ("TODOS", None, "") and str(mes).upper() != "TODOS" and d.month != int(mes):
return False
if dia not in ("TODOS", None, "") and str(dia).upper() != "TODOS" and d.day != int(dia):
return False
except (ValueError, TypeError):
return False
return True
@@ -446,9 +449,12 @@ def matriculas_por_dia(matriculas, cursos, ano, mes, dia):
import calendar
if mes not in ("TODOS", None) and ano not in ("TODOS", None):
ndias = calendar.monthrange(int(ano), int(mes))[1]
return [{"dia": d, "cantidad": conteo.get(d, 0), "detalle": _detalle(d)}
for d in range(1, ndias + 1)]
try:
ndias = calendar.monthrange(int(ano), int(mes))[1]
return [{"dia": d, "cantidad": conteo.get(d, 0), "detalle": _detalle(d)}
for d in range(1, ndias + 1)]
except (ValueError, TypeError):
pass
return [{"dia": d, "cantidad": conteo[d], "detalle": _detalle(d)}
for d in sorted(conteo.keys())]
@@ -465,8 +471,11 @@ def leads_por_dia(leads, ano, mes, dia):
proc[d] = proc.get(d, 0) + 1
import calendar
if mes not in ("TODOS", None) and ano not in ("TODOS", None):
ndias = calendar.monthrange(int(ano), int(mes))[1]
dias = range(1, ndias + 1)
try:
ndias = calendar.monthrange(int(ano), int(mes))[1]
dias = range(1, ndias + 1)
except (ValueError, TypeError):
dias = sorted(set(list(tot.keys()) + list(proc.keys())))
else:
dias = sorted(set(list(tot.keys()) + list(proc.keys())))
return [{"dia": d, "totales": tot.get(d, 0), "procesados": proc.get(d, 0)} for d in dias]