"""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