Spaces:
Running on T4
Running on T4
Download backend/app/common/names.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/common/names.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/app/common/names.py
-
curl -L -o names.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/common/names.py
552 Bytes
| """Display names for a set of accounts in one query.""" | |
| from collections.abc import Iterable | |
| from uuid import UUID | |
| from sqlalchemy import select | |
| from sqlalchemy.ext.asyncio import AsyncSession | |
| from app.modules.accounts.models import Account | |
| async def account_names(session: AsyncSession, ids: Iterable[UUID | None]) -> dict[UUID, str | None]: | |
| wanted = {i for i in ids if i} | |
| if not wanted: | |
| return {} | |
| rows = await session.execute(select(Account.id, Account.name).where(Account.id.in_(wanted))) | |
| return {i: n for i, n in rows} | |