Skip to content

Commit

Permalink
🐛 avoid errors due to addition of managers to FPL
Browse files Browse the repository at this point in the history
  • Loading branch information
jack89roberts committed Jan 24, 2025
1 parent 5e1a630 commit 22eeca1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion airsenal/framework/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
map between different conventions used in different data sources.
"""

positions = {1: "GK", 2: "DEF", 3: "MID", 4: "FWD"}
positions = {1: "GK", 2: "DEF", 3: "MID", 4: "FWD", 5: "MNG"}

alternative_team_names = {
"ARS": ["1", "Arsenal", "Arsenal FC"],
Expand Down
12 changes: 8 additions & 4 deletions airsenal/framework/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ def get_next_season(season: str) -> str:
"""
start_year = int(season[:2])
end_year = int(season[2:])
next_start_year = f"0{start_year+1}" if start_year + 1 < 10 else str(start_year + 1)
next_end_year = f"0{end_year+1}" if end_year + 1 < 10 else str(end_year + 1)
next_start_year = (
f"0{start_year + 1}" if start_year + 1 < 10 else str(start_year + 1)
)
next_end_year = f"0{end_year + 1}" if end_year + 1 < 10 else str(end_year + 1)
return f"{next_start_year}{next_end_year}"


Expand Down Expand Up @@ -683,6 +685,9 @@ def list_players(
q = q.filter_by(team=team)
if position != "all":
q = q.filter_by(position=position)
else:
# exclude managers
q = q.filter(PlayerAttributes.position != "MNG")
if len(gameweeks) > 1:
#  Sort query results by order of gameweeks - i.e. make sure the input
# query gameweek comes first.
Expand Down Expand Up @@ -1115,8 +1120,7 @@ def get_top_predicted_points(

discord_embed = {
"title": "AIrsenal webhook",
"description": f"PREDICTED TOP {n_players} "
f"PLAYERS FOR GAMEWEEK(S) {gameweek}:",
"description": f"PREDICTED TOP {n_players} PLAYERS FOR GAMEWEEK(S) {gameweek}:",
"color": 0x35A800,
"fields": [],
}
Expand Down
1 change: 1 addition & 0 deletions airsenal/scripts/fill_player_attributes_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Fill the "Player" table with info from this and past seasonss FPL
"""

import json
import os
from typing import List, Optional
Expand Down

0 comments on commit 22eeca1

Please sign in to comment.