from repositories.match_repository import upsert_match_by_team_external_ids


def sync_matches(matches_data: list[dict]) -> None:
    for match in matches_data:
        upsert_match_by_team_external_ids(
            external_id=match["external_id"],
            home_team_external_id=match["home_team_external_id"],
            away_team_external_id=match["away_team_external_id"],
            match_date=match.get("match_date"),
            status=match.get("status", "scheduled"),
            home_score=match.get("home_score"),
            away_score=match.get("away_score"),
            tour=match.get("tour"),
            season=match.get("season"),
            place=match.get("place"),
            date_raw=match.get("date_raw"),
            score_add=match.get("score_add"),
        )