feat: 1-to-1 message render + web data-lake backend
This commit is contained in:
1 parent
f0afb7ec5b
commit
75425d1bee
110 files changed
+10199
-54
No files matched your search
@@ -17,6 +17,26 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8::jsonb)
|
||||
ON CONFLICT (account_id, chat_id, message_id, user_id) DO NOTHING
|
||||
"""
|
||||
|
||||
_LATEST_TITLE = """
|
||||
SELECT title FROM chat_history
|
||||
WHERE account_id = $1 AND chat_id = $2 AND title IS NOT NULL
|
||||
ORDER BY ts DESC LIMIT 1
|
||||
"""
|
||||
|
||||
_LATEST_PHOTO = """
|
||||
SELECT photo_unique_id FROM chat_history
|
||||
WHERE account_id = $1 AND chat_id = $2 AND photo_unique_id IS NOT NULL
|
||||
ORDER BY ts DESC LIMIT 1
|
||||
"""
|
||||
|
||||
|
||||
async def get_latest_chat_meta(
|
||||
pool: asyncpg.Pool, account_id: int, chat_id: int
|
||||
) -> tuple[str | None, str | None]:
|
||||
title = await pool.fetchval(_LATEST_TITLE, account_id, chat_id)
|
||||
photo_unique_id = await pool.fetchval(_LATEST_PHOTO, account_id, chat_id)
|
||||
return title, photo_unique_id
|
||||
|
||||
|
||||
async def insert_chat_history( # noqa: PLR0913
|
||||
pool: asyncpg.Pool,
|
||||
|
||||
Reference in new issue
Block a user