Add inline comments to core modules and code review notes
Added explanatory comments to server.py, freshrss_pipeline.py, pipeline.py, freshrss.py, keyword_index.py, summary_loop.py, and filters/engine.py. Also added CODE_REVIEW.md with prioritized improvement suggestions.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
# FreshRSS 全链路管道:拉取未读条目 -> 内容提取 -> LLM 摘要 -> 规则过滤 ->
|
||||
# 构建 OpenClaw delivery payload -> 写盘 -> 词元统计 -> 标记已读。
|
||||
# 生产入口:run_freshrss_pipeline(),由 MCP 工具 run_freshrss_openclaw_pipeline 调用。
|
||||
|
||||
import json
|
||||
import os
|
||||
from datetime import UTC, date, datetime
|
||||
@@ -46,6 +50,7 @@ def _load_json(path: Path) -> dict[str, Any]:
|
||||
|
||||
|
||||
def _load_required_env(name: str, value: str | None) -> str:
|
||||
# 优先使用传入的 value,否则读取同名环境变量;两者均缺失时抛出 RuntimeError
|
||||
resolved = value or os.environ.get(name)
|
||||
if not resolved:
|
||||
raise RuntimeError(f"Missing required value: {name}.")
|
||||
@@ -137,6 +142,7 @@ def run_freshrss_pipeline(
|
||||
item_reports: list[dict[str, Any]] = []
|
||||
|
||||
for index, item in enumerate(items, start=1):
|
||||
# 逐条处理:提取 -> 摘要 -> 过滤 -> 候选构建;任一步骤失败则记录状态后 continue
|
||||
item_key = f"item-{index:02d}"
|
||||
item_path = _maybe_path(debug_artifacts, resolved_output_dir / "items" / f"{item_key}.item.json")
|
||||
extracted_path = _maybe_path(debug_artifacts, resolved_output_dir / "extracted" / f"{item_key}.extracted.json")
|
||||
@@ -256,6 +262,7 @@ def run_freshrss_pipeline(
|
||||
|
||||
marked_count = 0
|
||||
if mark_read and delivered_item_ids:
|
||||
# 仅标记成功投递(delivered)的 item;drop/review 的 item 保持未读状态
|
||||
client.mark_items_as_read(auth_token=auth_token, item_ids=delivered_item_ids)
|
||||
marked_count = len({item_id for item_id in delivered_item_ids if item_id})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user