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
@@ -2,13 +2,19 @@ import asyncpg
|
||||
|
||||
from utils.read.models import Page, PeerHistoryView, PeerView, StoryView
|
||||
|
||||
_PEER_COLS = (
|
||||
"peer_id, first_name, last_name, username, phone, photo_unique_id, "
|
||||
"is_deleted_account, updated_at, "
|
||||
"EXISTS (SELECT 1 FROM avatars a WHERE a.account_id = peers.account_id "
|
||||
"AND a.owner_id = peers.peer_id) AS has_avatar"
|
||||
)
|
||||
|
||||
|
||||
async def get_peer(
|
||||
pool: asyncpg.Pool, account_id: int, peer_id: int
|
||||
) -> PeerView | None:
|
||||
row = await pool.fetchrow(
|
||||
"SELECT peer_id, first_name, last_name, username, phone, "
|
||||
"photo_unique_id, is_deleted_account, updated_at FROM peers "
|
||||
f"SELECT {_PEER_COLS} FROM peers " # noqa: S608
|
||||
"WHERE account_id = $1 AND peer_id = $2",
|
||||
account_id,
|
||||
peer_id,
|
||||
@@ -16,6 +22,20 @@ async def get_peer(
|
||||
return PeerView(**dict(row)) if row else None
|
||||
|
||||
|
||||
async def get_peers(
|
||||
pool: asyncpg.Pool, account_id: int, ids: list[int]
|
||||
) -> list[PeerView]:
|
||||
if not ids:
|
||||
return []
|
||||
rows = await pool.fetch(
|
||||
f"SELECT {_PEER_COLS} FROM peers " # noqa: S608
|
||||
"WHERE account_id = $1 AND peer_id = ANY($2)",
|
||||
account_id,
|
||||
ids,
|
||||
)
|
||||
return [PeerView(**dict(row)) for row in rows]
|
||||
|
||||
|
||||
async def get_peer_history(
|
||||
pool: asyncpg.Pool, account_id: int, peer_id: int
|
||||
) -> list[PeerHistoryView]:
|
||||
|
||||
Reference in new issue
Block a user