feat(growth): close same-item reconciliation loop

This commit is contained in:
ogt
2026-07-14 21:03:25 +08:00
parent 15a2914001
commit ab68fec9ed
16 changed files with 1383 additions and 106 deletions

View File

@@ -2517,8 +2517,26 @@ def run_pchome_growth_momo_backfill_task():
before_stats = data.get("before_stats") or {}
after_stats = data.get("after_stats") or {}
sync_result = data.get("external_offer_sync") or {}
post_verifier = data.get("post_verifier") or {}
receipt_persistence = data.get("receipt_persistence") or {}
identity = data.get("identity") or {}
terminal_status = str(data.get("terminal_status") or "")
stats = {
"status": "Success" if result.get("success") else "Skipped",
"status": (
"Success"
if result.get("success") and terminal_status.startswith("verified")
else "Degraded"
if terminal_status.startswith(("degraded", "partial"))
else "Failed"
if not result.get("success")
else "Skipped"
),
"contract_version": data.get("contract_version"),
"trace_id": identity.get("trace_id"),
"run_id": identity.get("run_id"),
"work_item_id": identity.get("work_item_id"),
"terminal_status": terminal_status,
"next_machine_action": data.get("next_machine_action"),
"scanned_products": data.get("scanned_products", 0),
"candidate_count": data.get("candidate_count", 0),
"auto_compare_count": data.get("auto_compare_count", 0),
@@ -2530,10 +2548,21 @@ def run_pchome_growth_momo_backfill_task():
"mapped_count_before": before_stats.get("mapped_count"),
"mapped_count_after": after_stats.get("mapped_count"),
"needs_mapping_count_after": after_stats.get("needs_mapping_count"),
"comparison_ready_delta": post_verifier.get("comparison_ready_delta", 0),
"count_coverage_delta": post_verifier.get("count_coverage_delta", 0),
"revenue_coverage_before": (post_verifier.get("before") or {}).get("revenue_coverage_rate"),
"revenue_coverage_after": (post_verifier.get("after") or {}).get("revenue_coverage_rate"),
"revenue_coverage_delta": post_verifier.get("revenue_coverage_delta", 0),
"post_verifier_status": post_verifier.get("status"),
"post_verifier_passed": post_verifier.get("all_checks_passed", False),
"receipt_written_count": receipt_persistence.get("written_count", 0),
"receipt_readback_count": receipt_persistence.get("readback_count", 0),
"receipt_status": receipt_persistence.get("status"),
"message": result.get("message"),
}
logging.info(
"[Scheduler] [PChomeGrowthMomoBackfill] 完成 | scanned=%s candidates=%s auto=%s written=%s review=%s mapping=%s%%%s%%",
"[Scheduler] [PChomeGrowthMomoBackfill] 完成 | terminal=%s scanned=%s candidates=%s auto=%s written=%s review=%s mapping=%s%%%s%% revenue_coverage=%s%%%s%% receipts=%s/%s",
stats["terminal_status"],
stats["scanned_products"],
stats["candidate_count"],
stats["auto_compare_count"],
@@ -2541,6 +2570,10 @@ def run_pchome_growth_momo_backfill_task():
stats["review_count"],
stats["mapping_rate_before"],
stats["mapping_rate_after"],
stats["revenue_coverage_before"],
stats["revenue_coverage_after"],
stats["receipt_readback_count"],
stats["receipt_written_count"],
)
_save_stats('pchome_growth_momo_backfill', stats)