refactor(fudai): 抽 run_once_basic 中"单间模式清理过期预约"块到 cleanup_expired_reservations_single_room

将单间模式下"清理过期预约"逻辑(约 24 行)抽到 helper:
- 写说明日志
- 调用 douyin_reservation_logic.cleanup_expired_reservations
- 异常时记录错误日志

douyin_fudai.py: 1688 → 1670 行 (-18)
fudai_detail_helpers.py: 2242 → 2273 行

验证:
- pytest 1013 passed
- compile OK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
CodexandClaude Opus 4.7 committed 2026-05-22 12:15:56 +08:00
1 parent 798286776d
commit 43da92f6e6
2 files changed
+35 -22

No files matched your search

+4 -22
View File
@@ -926,29 +926,11 @@ class fudai_analyse:
# 抢占逻辑已删除,直接继续处理
else:
# 单间模式:不需要回退,预约会在当前直播间自动识别和参与
# 只需要清理过期的预约
try:
self._log_kv(
"预约",
"[预约] 单间模式(needswitch=False):不执行预约回退,预约会在当前直播间自动识别和参与",
reservations_count=(
len(self.reservations) if self.reservations else 0
),
)
from douyin.core.fudai_modules.fudai_detail_helpers import (
cleanup_expired_reservations_single_room,
)
# use module-level `douyin_reservation_logic`
douyin_reservation_logic.cleanup_expired_reservations(
self, self.reservations, _write_state
)
except Exception as exc:
try:
self._log_kv(
"预约",
"[预约] 单间模式下清理过期预约时出错",
error=str(exc),
)
except Exception:
pass
cleanup_expired_reservations_single_room(self, _write_state)
except Exception:
pass
@@ -42,6 +42,37 @@ def log_screenshot_failed(
pass
def cleanup_expired_reservations_single_room(analyser, write_state_callback) -> None:
"""run_once_basic 单间模式(needswitch=False)下清理过期预约。
单间模式不切换直播间,预约会在当前直播间自动识别和参与,因此只需要
调用 douyin_reservation_logic.cleanup_expired_reservations 清理过期项。
"""
from douyin.reservation import reservation_logic as douyin_reservation_logic
try:
analyser._log_kv(
"预约",
"[预约] 单间模式(needswitch=False):不执行预约回退,预约会在当前直播间自动识别和参与",
reservations_count=(
len(analyser.reservations) if analyser.reservations else 0
),
)
douyin_reservation_logic.cleanup_expired_reservations(
analyser, analyser.reservations, write_state_callback
)
except Exception as exc:
try:
analyser._log_kv(
"预约",
"[预约] 单间模式下清理过期预约时出错",
error=str(exc),
)
except Exception:
pass
def reset_to_first_room_after_all_reservations_done(
analyser, swipe_down_back_callback
) -> bool: