fix(scraper): 补_room_watermarks函数定义(增量同步时引用但定义在编辑中丢失,导致群消息扫描崩溃)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
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
@@ -571,6 +571,20 @@ async def _discover_conversations(channel: str, voice_channel: str) -> list[tupl
|
|||||||
return fresh + known
|
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]:
|
async def _conversation_watermarks(channel: str) -> dict[tuple[str, str], int]:
|
||||||
"""每对话的本地最新消息时间(ms)——增量同步水位。"""
|
"""每对话的本地最新消息时间(ms)——增量同步水位。"""
|
||||||
from app.db.base import async_engine
|
from app.db.base import async_engine
|
||||||
|
|||||||
Reference in New Issue
Block a user