feat: 评估按拆除日的前一周和当周取 4G 周表,MR 和 5G 仍用模拟数据
This commit is contained in:
@@ -17,13 +17,11 @@ from app.db import session_scope
|
||||
from app.evaluate.compute import EvalFailure, evaluate_site
|
||||
from app.evaluate.demand import KIND_LABELS, DemandRow, SiteGroup
|
||||
from app.evaluate.report import Item1, NeighborGroup, write_dixiao, write_pinduan
|
||||
from app.evaluate.sources import METRICS_MOCKED, build_sources, eval_mode
|
||||
from app.evaluate.sources import MetricError, build_sources, mock_notice
|
||||
from app.models import EvalJob, EvalTask, utcnow
|
||||
|
||||
logger = logging.getLogger("decom")
|
||||
JOB_FINAL = ("done", "partial", "failed")
|
||||
MOCK_NOTICE = "流量和质量指标暂为模拟数据,接入即席查询后替换"
|
||||
GONGCAN_MOCK_NOTICE = "演示模式:工参也是模拟数据,站点、距离和日期都不是现网的"
|
||||
MAX_WARNINGS = 300
|
||||
|
||||
|
||||
@@ -122,10 +120,10 @@ def execute_task(task_id: int) -> None:
|
||||
try:
|
||||
if group.removal is None:
|
||||
raise EvalFailure("缺少拆除日期")
|
||||
gongcan, metrics = build_sources(owner_kind, owner_id)
|
||||
gongcan, metrics = build_sources(owner_kind, owner_id, city)
|
||||
payload = evaluate_site(group, city, china_today(), gongcan, metrics, stage=lambda label: _stage(task_id, label))
|
||||
_finish_task(task_id, "done", payload=payload)
|
||||
except (EvalFailure, GongcanError) as exc:
|
||||
except (EvalFailure, GongcanError, MetricError) as exc:
|
||||
_finish_task(task_id, "failed", error=str(exc) or "评估失败")
|
||||
except Exception as exc:
|
||||
logger.exception("评估站点 %s 出错", task_id)
|
||||
@@ -207,9 +205,7 @@ def finalize_job(job_id: int) -> None:
|
||||
|
||||
|
||||
def _write_results(job_id: int, title: str, entries: list[dict]) -> tuple[list[dict], list[str]]:
|
||||
warnings: list[str] = [MOCK_NOTICE] if METRICS_MOCKED else []
|
||||
if eval_mode() == "mock":
|
||||
warnings.append(GONGCAN_MOCK_NOTICE)
|
||||
warnings: list[str] = [mock_notice()]
|
||||
for entry in entries:
|
||||
site = entry["payload"].get("site") or entry["key"]
|
||||
if entry["status"] == "failed":
|
||||
|
||||
Reference in New Issue
Block a user