fix: group resumen by factura+tipo only, not cedula

Grouping by cedula caused envíos with null/different cedula to split
into separate groups, making success envíos invisible — factura 4989
showed error persistente despite having a success send.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-26 18:09:42 -05:00
co-authored by Claude Sonnet 4.6
parent ab2ef167f9
commit 6e9ee32646
+5 -2
View File
@@ -219,7 +219,10 @@ async def resumen_page(
rows = conn.execute(f"""
SELECT
factura, tipo, contrato, cedula, idrecepcion,
factura, tipo,
MAX(contrato) AS contrato,
MIN(cedula) AS cedula,
MAX(idrecepcion) AS idrecepcion,
COUNT(*) AS intentos,
SUM(CASE WHEN status != 'error' THEN 1 ELSE 0 END) AS exitos,
MIN(created_at) AS primer_envio,
@@ -232,7 +235,7 @@ async def resumen_page(
END AS estado_final
FROM envios
WHERE DATE(created_at) = ? {where_extra}
GROUP BY factura, tipo, contrato, cedula, idrecepcion
GROUP BY factura, tipo
ORDER BY estado_final, tipo, factura
""", params_q).fetchall()