English names: orchestration (cycle, context, runner, repositories), its steps, fields and CLI, recomputation, follow_up and reports
This commit is contained in:
@@ -21,7 +21,7 @@ from webapi.imports.services.import_service import (
|
||||
serialize_errors,
|
||||
validate_source,
|
||||
)
|
||||
from webapi.indicadores_vivos import DOMINIOS, ColaDeRecalculo
|
||||
from webapi.recomputation import DOMAINS, RecomputationQueue
|
||||
from webapi.imports.services.introspection_service import (
|
||||
detect_pdf,
|
||||
document_report,
|
||||
@@ -321,9 +321,9 @@ def commit():
|
||||
finally:
|
||||
import_audit.record(audit)
|
||||
recalculating = False
|
||||
if audit.domain in DOMINIOS and any(r.created or r.updated for r in results):
|
||||
if audit.domain in DOMAINS and any(r.created or r.updated for r in results):
|
||||
try:
|
||||
ColaDeRecalculo().solicitar(audit.domain)
|
||||
RecomputationQueue().request_run(audit.domain)
|
||||
recalculating = True
|
||||
except OSError:
|
||||
# The rows are already saved; failing here would invite a duplicate retry.
|
||||
|
||||
@@ -3,13 +3,13 @@ indicator recomputation. Nothing here returns row-level data."""
|
||||
from flask import Blueprint, Response, jsonify, request
|
||||
|
||||
from webapi.imports import audit as import_audit
|
||||
from webapi.indicadores_vivos import DOMINIOS, ColaDeRecalculo
|
||||
from webapi.recomputation import DOMAINS, RecomputationQueue
|
||||
|
||||
reportes_bp = Blueprint("reportes", __name__)
|
||||
reports_bp = Blueprint("reportes", __name__)
|
||||
|
||||
|
||||
@reportes_bp.get("/importaciones")
|
||||
def importaciones():
|
||||
@reports_bp.get("/importaciones")
|
||||
def import_log():
|
||||
"""Totals per target over every logged attempt, plus the latest attempts
|
||||
(`?limite=50`, newest first; `?dominio=cacu` to filter)."""
|
||||
records = import_audit.default_sink().read()
|
||||
@@ -23,8 +23,8 @@ def importaciones():
|
||||
return jsonify({"resumen": import_audit.summarize(records), "intentos": list(reversed(records))[:limit]})
|
||||
|
||||
|
||||
@reportes_bp.get("/importaciones/descarga")
|
||||
def importaciones_descarga():
|
||||
@reports_bp.get("/importaciones/descarga")
|
||||
def import_log_download():
|
||||
"""The raw log, one JSON object per line."""
|
||||
sink = import_audit.default_sink()
|
||||
body = sink.path.read_bytes() if sink.path.exists() else b""
|
||||
@@ -35,15 +35,15 @@ def importaciones_descarga():
|
||||
)
|
||||
|
||||
|
||||
@reportes_bp.get("/indicadores")
|
||||
def indicadores_estado():
|
||||
@reports_bp.get("/indicadores")
|
||||
def recomputation_status():
|
||||
"""Per domain: state of the last recomputation and whether another is pending."""
|
||||
return jsonify(ColaDeRecalculo().estado())
|
||||
return jsonify(RecomputationQueue().status())
|
||||
|
||||
|
||||
@reportes_bp.post("/indicadores/<dominio>/recalcular")
|
||||
def indicadores_recalcular(dominio: str):
|
||||
if dominio not in DOMINIOS:
|
||||
@reports_bp.post("/indicadores/<dominio>/recalcular")
|
||||
def recompute(dominio: str):
|
||||
if dominio not in DOMAINS:
|
||||
return jsonify({"error": f"dominio desconocido: {dominio}"}), 404
|
||||
ColaDeRecalculo().solicitar(dominio)
|
||||
RecomputationQueue().request_run(dominio)
|
||||
return jsonify({"pendiente": True}), 202
|
||||
Reference in New Issue
Block a user