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

23
backend/.env Normal file
View File

@@ -0,0 +1,23 @@
PG_HOST=191.98.134.81
PG_DATABASE=chatwoot_production
PG_USER=postgres
PG_PASSWORD=2165$%sd3%DFG
PG_PORT=5432
SQL_SERVER=191.98.134.80
SQL_DATABASE=BDUS_CK000040_0001
SQL_USERNAME=ASEBASTIAN
SQL_PASSWORD=24MY36$z>&Uf
GITHUB_BASE=https://raw.githubusercontent.com/aron1798/prueba1/main/DASHBOARD_LEADS
SUPABASE_URL=https://ogzjtkxnfswpbmnbhnjd.supabase.co
SUPABASE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9nemp0a3huZnN3cGJtbmJobmpkIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3NjYzNDk4MywiZXhwIjoyMDkyMjEwOTgzfQ.D7XB6GIs8UvI97lcMdf6Y6-8ON2ENhh0DOaiMro2f9Y
SUPABASE_TABLA_LEADS=datos_unificados
SUPABASE_PAUTA_URL=https://uztqscimtsihrzgybsyb.supabase.co
SUPABASE_PAUTA_KEY=sb_publishable_aJCh5J6UghfKmSz6Swy4iA_orAqeHb7
SUPABASE_TABLA_PAUTA=basebi_programacion
CARTERA_URL=https://uztqscimtsihrzgybsyb.supabase.co
CARTERA_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV6dHFzY2ltdHNpaHJ6Z3lic3liIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc2MTMyMzQ0MCwiZXhwIjoyMDc2ODk5NDQwfQ.pvqzwJ7fBxggNka3oga7SdhiADIgIVKGEuxGbzHQj0E
SUPABASE_TABLA_CARTERA=cartera_junta
SUPABASE_TABLA_ALIAS=alias_normalizacion
SUPABASE_TABLA_CONJUNTO=conjunto_pauta
META_CSV_URL=https://docs.google.com/spreadsheets/d/e/2PACX-1vQa5BFEeF-p0-6-FuEXDXT4eb_ZK0fkYgLMxK_Ly3EJJPwQBsYDfNsSW09ppMNrH2LIiwVdAnC5q64C/pub?gid=1241390845&single=true&output=csv
CORS_ORIGINS=https://dashboard-leads.escueladerefrigeracion.lat,http://dashboard-leads.escueladerefrigeracion.lat,http://localhost:5174,http://localhost:3000,*

View File

@@ -2,14 +2,14 @@
PG_HOST=191.98.134.81 PG_HOST=191.98.134.81
PG_DATABASE=chatwoot_production PG_DATABASE=chatwoot_production
PG_USER=postgres PG_USER=postgres
PG_PASSWORD=tu_password_aqui PG_PASSWORD=2165$%sd3%DFG
PG_PORT=5432 PG_PORT=5432
# Configuración de Base de Datos SQL Server # Configuración de Base de Datos SQL Server
SQL_SERVER=191.98.134.80 SQL_SERVER=191.98.134.80
SQL_DATABASE=BDUS_CK000040_0001 SQL_DATABASE=BDUS_CK000040_0001
SQL_USERNAME=ASEBASTIAN SQL_USERNAME=ASEBASTIAN
SQL_PASSWORD=tu_password_aqui SQL_PASSWORD=24MY36$z>&Uf
# Repositorio GitHub # Repositorio GitHub
GITHUB_BASE=https://raw.githubusercontent.com/aron1798/prueba1/main/DASHBOARD_LEADS GITHUB_BASE=https://raw.githubusercontent.com/aron1798/prueba1/main/DASHBOARD_LEADS

View File

@@ -20,13 +20,13 @@ class DataManager:
self.pg_host = os.getenv("PG_HOST", "191.98.134.81") self.pg_host = os.getenv("PG_HOST", "191.98.134.81")
self.pg_db = os.getenv("PG_DATABASE", "chatwoot_production") self.pg_db = os.getenv("PG_DATABASE", "chatwoot_production")
self.pg_user = os.getenv("PG_USER", "postgres") self.pg_user = os.getenv("PG_USER", "postgres")
self.pg_pass = os.getenv("PG_PASSWORD", "") self.pg_pass = os.getenv("PG_PASSWORD", "2165$%sd3%DFG")
self.pg_port = os.getenv("PG_PORT", "5432") self.pg_port = os.getenv("PG_PORT", "5432")
# SQL Server (Académico) # SQL Server (Académico)
self.sql_server = os.getenv("SQL_SERVER", "191.98.134.80") self.sql_server = os.getenv("SQL_SERVER", "191.98.134.80")
self.sql_db = os.getenv("SQL_DATABASE", "BDUS_CK000040_0001") self.sql_db = os.getenv("SQL_DATABASE", "BDUS_CK000040_0001")
self.sql_user = os.getenv("SQL_USERNAME", "") self.sql_user = os.getenv("SQL_USERNAME", "ASEBASTIAN")
self.sql_pass = os.getenv("SQL_PASSWORD", "") self.sql_pass = os.getenv("SQL_PASSWORD", "24MY36$z>&Uf")
# GitHub # GitHub
base = os.getenv("GITHUB_BASE", "") base = os.getenv("GITHUB_BASE", "")
self.github_campanias_url = f"{base}/campanias.json" if base else "" self.github_campanias_url = f"{base}/campanias.json" if base else ""

View File

@@ -122,12 +122,12 @@ class DataManager:
self.pg_host = os.getenv("PG_HOST", "191.98.134.81") self.pg_host = os.getenv("PG_HOST", "191.98.134.81")
self.pg_db = os.getenv("PG_DATABASE", "chatwoot_production") self.pg_db = os.getenv("PG_DATABASE", "chatwoot_production")
self.pg_user = os.getenv("PG_USER", "postgres") self.pg_user = os.getenv("PG_USER", "postgres")
self.pg_pass = os.getenv("PG_PASSWORD", "") self.pg_pass = os.getenv("PG_PASSWORD", "2165$%sd3%DFG")
self.pg_port = os.getenv("PG_PORT", "5432") self.pg_port = os.getenv("PG_PORT", "5432")
self.sql_server = os.getenv("SQL_SERVER", "191.98.134.80") self.sql_server = os.getenv("SQL_SERVER", "191.98.134.80")
self.sql_db = os.getenv("SQL_DATABASE", "BDUS_CK000040_0001") self.sql_db = os.getenv("SQL_DATABASE", "BDUS_CK000040_0001")
self.sql_user = os.getenv("SQL_USERNAME", "") self.sql_user = os.getenv("SQL_USERNAME", "ASEBASTIAN")
self.sql_pass = os.getenv("SQL_PASSWORD", "") self.sql_pass = os.getenv("SQL_PASSWORD", "24MY36$z>&Uf")
def pg_conn(self): def pg_conn(self):
import psycopg2 import psycopg2

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

View File

@@ -392,8 +392,11 @@ def matriz_asignados(ano="TODOS", mes="TODOS", dia="TODOS"):
rows = _leads_asignados_crudos() rows = _leads_asignados_crudos()
# dias del mes filtrado (columnas) # dias del mes filtrado (columnas)
if mes not in ("TODOS", None) and ano not in ("TODOS", None): if mes not in ("TODOS", None) and ano not in ("TODOS", None):
try:
ndias = calendar.monthrange(int(ano), int(mes))[1] ndias = calendar.monthrange(int(ano), int(mes))[1]
dias_cols = list(range(1, ndias + 1)) dias_cols = list(range(1, ndias + 1))
except (ValueError, TypeError):
dias_cols = list(range(1, 32))
else: else:
dias_cols = list(range(1, 32)) dias_cols = list(range(1, 32))