refactor: bzzoiro.py 按管线拆分为 5 个模块

单文件 852 行按职责拆分,保持 BzzoiroSource 与 get_source("bzzoiro") 行为不变:
- bzzoiro_common  HTTP 抓取(多 key 轮换) + 字段转换原语
- bzzoiro_events   fetch_bzzoiro_events + BzzoiroSource.ingest + Bronze 补写
- bzzoiro_standings  standings 管线
- bzzoiro_stats     stats 回填
- pipeline_write    RawEvent/IngestFailure/DataLineage 写入助手

子模块运行期经聚合门面 src.data.bzzoiro 解析可替换协作者,
单文件时代的 bz.* monkeypatch 语义完全保留。
路由 import 已指向新模块(ingest.py / schedules.py)。
This commit is contained in:
shangfangjian
2026-09-21 23:27:48 +08:00
parent 7a5c695b89
commit 317a5e338a
10 changed files with 984 additions and 796 deletions
+3 -3
View File
@@ -175,7 +175,7 @@ class TestBzzoiroLineage:
return bad
def test_normalized_matches_carries_raw(self):
src = _read("data/bzzoiro.py")
src = _read("data/bzzoiro_events.py")
# 规范化结果必须与原始 event 成对保存
assert "normalized_matches.append((nm, raw))" in src, (
"normalized_matches 未携带 (nm, raw) 元组 —— raw 变量泄漏会回归 (P0-3)"
@@ -193,7 +193,7 @@ class TestBzzoiroLineage:
它不是 `raw.get(` 同一行,但同样正确。非法写法(回归)是直接
`existing_match.source_event_id = orphan_var`。
"""
src = _read("data/bzzoiro.py")
src = _read("data/bzzoiro_events.py")
seg = self._consume_loop_body(src)
bad = self._bad_assignments(seg)
assert len(bad) == 0, (
@@ -206,7 +206,7 @@ class TestBzzoiroLineage:
下游 `_backfill_stats` 里合法地在 ORM 对象上访问 `m.source_event_id`
(与配对 raw 无关)。若 seg 越界,test_no_orphan_raw_use 会误报。
"""
src = _read("data/bzzoiro.py")
src = _read("data/bzzoiro_events.py")
seg = self._consume_loop_body(src)
assert "m.source_event_id" not in seg, (
"循环体截取越界,扫到了下游 stats 管线 —— 会误报 P0-3"