baseball-engine / backend /app /modules /teams /repository.py
github-actions[bot]
Automated Deploy: 0d5b759d8eca219a25b3ab717925e73a66bbf4a4
2756f0f
Raw History Blame Contribute Delete
812 Bytes
"""Team queries, plus the account columns the teams module writes (coach name/focus, player team_id)."""
from uuid import UUID
from sqlalchemy import select
from app.common.base_repository import BaseRepository
from app.modules.accounts.models import Account
from app.modules.teams.models import Team
class TeamRepository(BaseRepository[Team]):
model = Team
async def by_code(self, code: str) -> Team | None:
return await self.first_by(code=code)
async def by_coach(self, coach_id: UUID) -> Team | None:
return await self.first_by(coach_id=coach_id)
async def coach_name(self, team: Team) -> str:
return await self.session.scalar(select(Account.name).where(Account.id == team.coach_id)) or ""
class MemberRepository(BaseRepository[Account]):
model = Account