from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession from app.models import Player # Shared by app/routers/matchmaking.py (queue join) and app/routers/matches.py # (match result reporting) -- both need "find this callsign's Player row, or # create one" with no account/auth system yet (see Player's own docstring). async def get_or_create_player(db: AsyncSession, callsign: str) -> Player: player = (await db.execute(select(Player).where(Player.callsign == callsign))).scalars().first() if player is None: player = Player(callsign=callsign) db.add(player) await db.commit() await db.refresh(player) return player