creación de scheduler.json para ejecución de servicio

This commit is contained in:
George committed 2026-08-04 09:34:44 -05:00
1 parent 839aad698d
commit 1c39f6f45f
11 files changed
+112 -400

No files matched your search

+10 -8
View File
@@ -3,6 +3,7 @@ from pathlib import Path
from datetime import datetime
from collections import Counter
# ============================================================================
try:
import matplotlib
matplotlib.use("Agg")
@@ -24,14 +25,14 @@ COLORS = {
}
CMAP = list(COLORS.values())
# ============================================================================
def _query(sql, params=()):
with sqlite3.connect(str(DB_PATH)) as conn:
conn.row_factory = sqlite3.Row
rows = conn.execute(sql, params).fetchall()
return [dict(r) for r in rows]
# ============================================================================
def reporte_texto():
print("\n" + "=" * 60)
print("📊 REPORTE DE FALLAS - SUNAT")
@@ -61,11 +62,11 @@ def reporte_texto():
for r in _query("SELECT DATE(fecha_ultimo) AS dia, COUNT(*) AS c FROM fallas GROUP BY dia ORDER BY dia"):
print(f" {r['dia']} → {r['c']} falla(s)")
# ============================================================================
def _color_error(error):
return COLORS.get(error, "#95a5a6")
# ============================================================================
def grafico_barras_errores():
data = _query("SELECT COUNT(*) AS c, error FROM fallas GROUP BY error ORDER BY c DESC")
if not data:
@@ -90,7 +91,7 @@ def grafico_barras_errores():
plt.close(fig)
return path
# ============================================================================
def grafico_barras_ruc():
data = _query("SELECT COUNT(*) AS c, ruc FROM fallas GROUP BY ruc ORDER BY c DESC LIMIT 10")
if not data:
@@ -115,7 +116,7 @@ def grafico_barras_ruc():
plt.close(fig)
return path
# ============================================================================
def grafico_torta():
data = _query("SELECT COUNT(*) AS c, error FROM fallas GROUP BY error ORDER BY c DESC")
if not data:
@@ -139,7 +140,7 @@ def grafico_torta():
plt.close(fig)
return path
# ============================================================================
def main():
reporte_texto()
@@ -161,6 +162,7 @@ def main():
print(f" {p.name}")
print(f"\n💡 Abre con: open {REPORTES_DIR}")
# ============================================================================
if __name__ == "__main__":
main()
# ============================================================================