perf(*): bound list queries, batch fetches, harden media downloads
This commit is contained in:
1 parent
9c12628304
commit
1fa4f18a9b
35 files changed
+473
-138
No files matched your search
@@ -10,6 +10,7 @@ from utils.policy import repository
|
||||
from utils.read import chats
|
||||
from utils.read.models import (
|
||||
DEFAULT_LIMIT,
|
||||
MAX_LIMIT,
|
||||
ChatListItem,
|
||||
MessageVersionView,
|
||||
MessageView,
|
||||
@@ -49,6 +50,14 @@ async def list_chats(
|
||||
)
|
||||
|
||||
|
||||
@router.get("/chats/batch")
|
||||
async def get_chats_batch(
|
||||
pool: FromDishka[asyncpg.Pool], account_id: AccountId, ids: Annotated[str, Query()]
|
||||
) -> list[ChatListItem]:
|
||||
parsed = [int(part) for part in ids.split(",") if part.strip()]
|
||||
return await chats.get_chats(pool, account_id, parsed[:MAX_LIMIT])
|
||||
|
||||
|
||||
@router.get("/chats/{chat_id}")
|
||||
async def get_chat(
|
||||
pool: FromDishka[asyncpg.Pool], chat_id: int, account_id: AccountId
|
||||
|
||||
Reference in new issue
Block a user