Extract three internal helpers to reduce the main function from ~330 lines to ~80 lines: - _process_item(): handles per-item extract/summarize/filter/build - _build_and_persist_delivery(): builds payload and persists keyword index - _build_run_report(): assembles status counts and run report dict No behavior changes. External signature and return shape unchanged.
1.3 KiB
1.3 KiB
代码审查建议(2026-03-28)
立即可改(低成本)
server.pycontext 通过临时文件传递绕路 —run_freshrss_pipeline改为同时接受dict | Path类型的 context,消除NamedTemporaryFile绕路(已修复)_load_required_env报错信息不区分"未传参数"还是"环境变量未设",改善调试体验evaluate_filter_rules决策逻辑歧义 —stop_on_match=True命中后应直接以该规则 decision 为最终结果,而非继续聚合所有 matched(已确认:当前规则集安全,在 filter-rule-engine-usage.md 补充了 drop 规则必须设 stop_on_match=true 的约束说明)
重构建议(中等成本)
run_freshrss_pipeline函数过长(约300行)— 拆分为_process_item()、_build_and_persist_delivery()、_build_run_report()三个内部函数,主函数只做编排(已完成)load_filter_rules每次 pipeline 调用都重新读文件 — 加模块级缓存,MCP 服务长期运行时避免重复 I/O
功能补全
mark_read只标记 delivered items,drop/review 的 item 下次仍会重复拉取 — 引入mark_read_all_processed选项,或在报告中明确标注- LLM 调用逐条串行 — 考虑用
asyncio+httpx.AsyncClient并发处理多条 item,减少整体延迟