This commit is contained in:
2026-04-22 13:02:49 +03:00
parent 5fb43e9b80
commit 7d804050f7
2 changed files with 15 additions and 14 deletions

View File

@@ -186,8 +186,7 @@ def mark_match_parse_error(external_id: str, error_text: str) -> None:
def get_player_id_by_name_and_team(full_name: str, team_id: int) -> int | None:
query = """
SELECT id,
position
SELECT id
FROM players
WHERE team_id = %s
AND LOWER(full_name) = LOWER(%s)
@@ -199,14 +198,15 @@ def get_player_id_by_name_and_team(full_name: str, team_id: int) -> int | None:
with conn.cursor() as cur:
cur.execute(query, (team_id, full_name.strip()))
row = cur.fetchone()
return row if row else None
return row[0] if row else None
finally:
conn.close()
def get_player_id_by_external_id(external_id: str) -> int | None:
query = """
SELECT id
SELECT id,
position
FROM players
WHERE external_id = %s
LIMIT 1;
@@ -217,7 +217,7 @@ def get_player_id_by_external_id(external_id: str) -> int | None:
with conn.cursor() as cur:
cur.execute(query, (str(external_id).strip(),))
row = cur.fetchone()
return row[0] if row else None
return row if row else None
finally:
conn.close()