浏览代码

fix: preserve enriched_at through sanitize_cluster_payload

The sanitizer was stripping enriched_at (and failure metadata) from
cluster payloads on every upsert. This caused the poller's DB cache
check to never hit — get_cluster_by_id always returned payloads without
enriched_at, so every cluster was re-enriched every poll cycle.

Fix: carry enriched_at, enrichment_failed_at, and enrichment_retry_count
from the input cluster into the sanitized output before the early return.
Lukas Goldschmidt 1 周之前
父节点
当前提交
065421f71f
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      news_mcp/storage/sqlite_store.py

+ 6 - 0
news_mcp/storage/sqlite_store.py

@@ -163,6 +163,12 @@ def sanitize_cluster_payload(cluster: dict[str, Any], *, include_resolutions: bo
     if not out.get("timestamp"):
         out["timestamp"] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S+00:00")
 
+    # Preserve enrichment metadata across sanitization so the
+    # poller's enriched_at cache check works on DB round-trips.
+    for _fld in ("enriched_at", "enrichment_failed_at", "enrichment_retry_count"):
+        if _fld in cluster:
+            out.setdefault(_fld, cluster[_fld])
+
     if not include_resolutions:
         return out