refactor: BSP推送提取公共函数 + 清理

- _push_bsp() 提取重复的key构造+推送逻辑
- bsp.klc None防护
- getattr替代hasattr+属性访问
- 修正首轮日志(不再写"不推送")

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
jackyu66git
2026-05-26 14:05:20 +08:00
co-authored by Claude Opus 4.7
parent a84a80cb62
commit 42296ef971
2 changed files with 18 additions and 13 deletions
+2 -2
View File
@@ -27,7 +27,7 @@ class ChanPivotMonitor:
self._current_bi_count: int = 0
self._current_is_sure: bool = False
self._current_state: Optional[dict] = None
self._duration_added_for_zs: set = set() # 已加入窗口的中枢 ID
self._duration_added_for_zs: set = set() # 已加入窗口的中枢 ID(上限 200
# ------------------------------------------------------------------
# Public API
@@ -87,7 +87,7 @@ class ChanPivotMonitor:
"gg": round(zs.gg, 6),
"dd": round(zs.dd, 6),
**features,
"start_time": str(zs.start_time) if hasattr(zs, "start_time") and zs.start_time else None,
"start_time": str(t) if (t := getattr(zs, "start_time", None)) else None,
}
# 中枢刚变为已确认时,将其 duration 加入滚动窗口