fix: fallback de credenciales DB y parseo seguro de parametros
This commit is contained in:
23
backend/.env
Normal file
23
backend/.env
Normal 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,*
|
||||
@@ -2,14 +2,14 @@
|
||||
PG_HOST=191.98.134.81
|
||||
PG_DATABASE=chatwoot_production
|
||||
PG_USER=postgres
|
||||
PG_PASSWORD=tu_password_aqui
|
||||
PG_PASSWORD=2165$%sd3%DFG
|
||||
PG_PORT=5432
|
||||
|
||||
# Configuración de Base de Datos SQL Server
|
||||
SQL_SERVER=191.98.134.80
|
||||
SQL_DATABASE=BDUS_CK000040_0001
|
||||
SQL_USERNAME=ASEBASTIAN
|
||||
SQL_PASSWORD=tu_password_aqui
|
||||
SQL_PASSWORD=24MY36$z>&Uf
|
||||
|
||||
# Repositorio GitHub
|
||||
GITHUB_BASE=https://raw.githubusercontent.com/aron1798/prueba1/main/DASHBOARD_LEADS
|
||||
|
||||
@@ -20,13 +20,13 @@ class DataManager:
|
||||
self.pg_host = os.getenv("PG_HOST", "191.98.134.81")
|
||||
self.pg_db = os.getenv("PG_DATABASE", "chatwoot_production")
|
||||
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")
|
||||
# SQL Server (Académico)
|
||||
self.sql_server = os.getenv("SQL_SERVER", "191.98.134.80")
|
||||
self.sql_db = os.getenv("SQL_DATABASE", "BDUS_CK000040_0001")
|
||||
self.sql_user = os.getenv("SQL_USERNAME", "")
|
||||
self.sql_pass = os.getenv("SQL_PASSWORD", "")
|
||||
self.sql_user = os.getenv("SQL_USERNAME", "ASEBASTIAN")
|
||||
self.sql_pass = os.getenv("SQL_PASSWORD", "24MY36$z>&Uf")
|
||||
# GitHub
|
||||
base = os.getenv("GITHUB_BASE", "")
|
||||
self.github_campanias_url = f"{base}/campanias.json" if base else ""
|
||||
|
||||
@@ -122,12 +122,12 @@ class DataManager:
|
||||
self.pg_host = os.getenv("PG_HOST", "191.98.134.81")
|
||||
self.pg_db = os.getenv("PG_DATABASE", "chatwoot_production")
|
||||
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.sql_server = os.getenv("SQL_SERVER", "191.98.134.80")
|
||||
self.sql_db = os.getenv("SQL_DATABASE", "BDUS_CK000040_0001")
|
||||
self.sql_user = os.getenv("SQL_USERNAME", "")
|
||||
self.sql_pass = os.getenv("SQL_PASSWORD", "")
|
||||
self.sql_user = os.getenv("SQL_USERNAME", "ASEBASTIAN")
|
||||
self.sql_pass = os.getenv("SQL_PASSWORD", "24MY36$z>&Uf")
|
||||
|
||||
def pg_conn(self):
|
||||
import psycopg2
|
||||
|
||||
@@ -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):
|
||||
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 d.month != int(mes):
|
||||
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 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 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):
|
||||
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):
|
||||
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]
|
||||
|
||||
@@ -392,8 +392,11 @@ def matriz_asignados(ano="TODOS", mes="TODOS", dia="TODOS"):
|
||||
rows = _leads_asignados_crudos()
|
||||
# dias del mes filtrado (columnas)
|
||||
if mes not in ("TODOS", None) and ano not in ("TODOS", None):
|
||||
try:
|
||||
ndias = calendar.monthrange(int(ano), int(mes))[1]
|
||||
dias_cols = list(range(1, ndias + 1))
|
||||
except (ValueError, TypeError):
|
||||
dias_cols = list(range(1, 32))
|
||||
else:
|
||||
dias_cols = list(range(1, 32))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user