refactor(fudai): 抽 run_once_basic 中"第一个预约检查日志"块到 log_first_reservation_check
将 40 行的纯日志块抽到 fudai_detail_helpers.log_first_reservation_check。 输出 needswitch 配置 + 队列长度 + 第一个预约的详细信息(future_ts、 剩余秒数、目标位置等)。 douyin_fudai.py: 2503 → 2468 行 (-35) fudai_detail_helpers.py: 1266 → 1311 行 验证: - pytest 1013 passed - compile OK Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7694e233f9
commit
e21e5a5fca
2 files changed
+49
-39
No files matched your search
@@ -888,46 +888,11 @@ class fudai_analyse:
|
||||
needswitch_cfg = True
|
||||
|
||||
# 添加详细的调试日志,确认 needswitch 的值和预约信息
|
||||
try:
|
||||
# 输出第一个预约的详细信息
|
||||
first_reservation_info = {}
|
||||
if self.reservations and len(self.reservations) > 0:
|
||||
first_r = self.reservations[0]
|
||||
try:
|
||||
ft = float(first_r.get("future_ts") or 0)
|
||||
from datetime import datetime
|
||||
from douyin.core.fudai_modules.fudai_detail_helpers import (
|
||||
log_first_reservation_check,
|
||||
)
|
||||
|
||||
now_ts = time.time()
|
||||
ft_str = (
|
||||
datetime.fromtimestamp(ft).strftime("%Y-%m-%d %H:%M:%S")
|
||||
if ft > 0
|
||||
else "无效"
|
||||
)
|
||||
remain_seconds = int(ft - now_ts) if ft > 0 else 0
|
||||
first_reservation_info = {
|
||||
"future_ts": int(ft) if ft > 0 else 0,
|
||||
"future_str": ft_str,
|
||||
"value": float(first_r.get("prize_value_yuan", 0)),
|
||||
"pos_seen": int(first_r.get("pos_seen", 0)),
|
||||
"remain_seconds": remain_seconds,
|
||||
"current_room_pos": int(
|
||||
getattr(self, "room_pos", 0) or 0
|
||||
),
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._log_kv(
|
||||
"预约",
|
||||
"[预约] run_once_basic:检查预约回退条件",
|
||||
needswitch_cfg=needswitch_cfg,
|
||||
reservations_count=(
|
||||
len(self.reservations) if self.reservations else 0
|
||||
),
|
||||
first_reservation=first_reservation_info,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
log_first_reservation_check(self, needswitch_cfg)
|
||||
|
||||
if needswitch_cfg:
|
||||
# 多间模式:需要回退到预约直播间
|
||||
|
||||
@@ -42,6 +42,51 @@ def log_screenshot_failed(
|
||||
pass
|
||||
|
||||
|
||||
def log_first_reservation_check(analyser, needswitch_cfg: bool) -> None:
|
||||
"""run_once_basic 步骤 0.1.3:记录第一个预约的检查日志(纯日志,无副作用)。
|
||||
|
||||
输出当前 needswitch 配置 + 队列长度 + 第一个预约的详细信息(future_ts、
|
||||
剩余秒数、目标位置等)。
|
||||
"""
|
||||
try:
|
||||
from datetime import datetime
|
||||
|
||||
first_reservation_info = {}
|
||||
if analyser.reservations and len(analyser.reservations) > 0:
|
||||
first_r = analyser.reservations[0]
|
||||
try:
|
||||
ft = float(first_r.get("future_ts") or 0)
|
||||
now_ts = time.time()
|
||||
ft_str = (
|
||||
datetime.fromtimestamp(ft).strftime("%Y-%m-%d %H:%M:%S")
|
||||
if ft > 0
|
||||
else "无效"
|
||||
)
|
||||
remain_seconds = int(ft - now_ts) if ft > 0 else 0
|
||||
first_reservation_info = {
|
||||
"future_ts": int(ft) if ft > 0 else 0,
|
||||
"future_str": ft_str,
|
||||
"value": float(first_r.get("prize_value_yuan", 0)),
|
||||
"pos_seen": int(first_r.get("pos_seen", 0)),
|
||||
"remain_seconds": remain_seconds,
|
||||
"current_room_pos": int(getattr(analyser, "room_pos", 0) or 0),
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] run_once_basic:检查预约回退条件",
|
||||
needswitch_cfg=needswitch_cfg,
|
||||
reservations_count=(
|
||||
len(analyser.reservations) if analyser.reservations else 0
|
||||
),
|
||||
first_reservation=first_reservation_info,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def log_reservation_check_status(analyser, high_value_enabled: bool) -> None:
|
||||
"""run_once_basic 步骤 0.1.2:记录预约回退的触发条件日志(纯日志,无副作用)。
|
||||
|
||||
|
||||
Reference in new issue
Block a user