from repositories.team_repository import upsert_team


def sync_teams(teams_data: list[dict]) -> None:
    for team in teams_data:
        upsert_team(
            external_id=team["external_id"],
            name=team["name"],
            logo_url=team["logo_url"],
            games=int(team.get("games", 0) or 0),
            wins=int(team.get("wins", 0) or 0),
            goals=int(team.get("goals", 0) or 0),
            tournaments=int(team.get("tournaments", 0) or 0),
        )