Initial commit - dashboard leads
This commit is contained in:
58
backend/diag_matri_50_vs_51.py
Normal file
58
backend/diag_matri_50_vs_51.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# diag_matri_50_vs_51.py
|
||||
# Busca la matricula de diferencia (dashboard 51 vs cmd 50) en TEAC agosto.
|
||||
# Replica EXACTAMENTE el bloque de la matriz del dashboard y compara.
|
||||
from datetime import datetime
|
||||
from collections import defaultdict
|
||||
import services as S
|
||||
import leads_logic as L
|
||||
|
||||
ANO, MES = 2026, 8
|
||||
ase = S._asesores(); amap = ase["map"]; lista = ase["lista"]
|
||||
|
||||
# ---- REPLICA EXACTA del bloque de matriz del dashboard ----
|
||||
GRUPOS = ["TEAC","TERC","SEMINARIOS","OTROS"]
|
||||
prog_tot = defaultdict(int)
|
||||
detalle = defaultdict(list) # grupo -> [matriculas]
|
||||
for m in S._matriculas_crudas():
|
||||
vend = S._norm_asesor(m.get("dsc_vendedor"), amap)
|
||||
if not vend:
|
||||
continue
|
||||
estado = str(m.get("estado_matricula") or "").strip().upper()
|
||||
if estado == "ANU":
|
||||
continue
|
||||
fm = L._to_date(m.get("fch_matricula"))
|
||||
if not L._en_periodo(fm, str(ANO), str(MES), "TODOS"):
|
||||
continue
|
||||
grupo = L.grupo_programa_curso(m.get("dsc_programa"))
|
||||
prog_tot[grupo] += 1
|
||||
detalle[grupo].append(m)
|
||||
|
||||
print("=== Conteo por grupo (replica dashboard) ===")
|
||||
tot=0
|
||||
for g in GRUPOS:
|
||||
print(f" {g:12} {prog_tot[g]}")
|
||||
tot+=prog_tot[g]
|
||||
print(f" TOTAL {tot}")
|
||||
|
||||
# ---- Detalle de TEAC: mostrar TODAS con num_matricula para ver duplicados/algo raro ----
|
||||
print(f"\n=== TEAC — {len(detalle['TEAC'])} matriculas (con num_matricula y num_indice) ===")
|
||||
for m in sorted(detalle['TEAC'], key=lambda x: str(x.get('fch_matricula'))):
|
||||
fm = L._to_date(m.get('fch_matricula'))
|
||||
print(f" mat={m.get('num_matricula')} idx={m.get('num_indice')} "
|
||||
f"{S._norm_asesor(m.get('dsc_vendedor'),amap):16} {str(fm)[:10]} "
|
||||
f"est={m.get('estado_matricula')} | {str(m.get('dsc_programa'))[:40]}")
|
||||
|
||||
# ---- Ver si hay matriculas cuyo asesor NO cae en los 8 (por eso el dashboard podria contar distinto) ----
|
||||
print(f"\n=== Matriculas agosto con asesor que NO es de los 8 (quedan fuera del cmd) ===")
|
||||
n_fuera=0
|
||||
for m in S._matriculas_crudas():
|
||||
estado = str(m.get("estado_matricula") or "").strip().upper()
|
||||
if estado == "ANU": continue
|
||||
fm = L._to_date(m.get("fch_matricula"))
|
||||
if not (fm and fm.year==ANO and fm.month==MES): continue
|
||||
vend = S._norm_asesor(m.get("dsc_vendedor"), amap)
|
||||
if not vend:
|
||||
n_fuera += 1
|
||||
print(f" mat={m.get('num_matricula')} asesor_original='{m.get('dsc_vendedor')}' "
|
||||
f"grupo={L.grupo_programa_curso(m.get('dsc_programa'))} est={estado}")
|
||||
print(f" -> {n_fuera} matriculas con asesor fuera de los 8")
|
||||
Reference in New Issue
Block a user