fix(scraper): 补_room_watermarks函数定义(增量同步时引用但定义在编辑中丢失,导致群消息扫描崩溃)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-24 14:15:37 +08:00
parent 8a99940554
commit 5effaac00b
4 changed files with 46835 additions and 0 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+14
View File
@@ -571,6 +571,20 @@ async def _discover_conversations(channel: str, voice_channel: str) -> list[tupl
return fresh + known
async def _room_watermarks() -> dict[str, int]:
"""每群本地最新消息时间(ms)——群消息增量水位(按 room_id)。"""
from app.db.base import async_engine
from sqlalchemy import text as sa_text
async with async_engine.connect() as conn:
result = await conn.execute(sa_text(
"SELECT room_id, max(timestamp) FROM message "
"WHERE room_id IS NOT NULL AND room_id != '' "
"GROUP BY room_id"
))
return {r[0]: r[1] or 0 for r in result.fetchall()}
async def _conversation_watermarks(channel: str) -> dict[tuple[str, str], int]:
"""每对话的本地最新消息时间(ms)——增量同步水位。"""
from app.db.base import async_engine