Skip to content

Commit

Permalink
[#638] fix ability to skip confirmation step in set lineup
Browse files Browse the repository at this point in the history
  • Loading branch information
jack89roberts committed Oct 1, 2023
1 parent aa7c7ab commit 986645d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion airsenal/scripts/make_transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def main():
confirm = args.confirm or False
try:
make_transfers(args.fpl_team_id, confirm)
set_lineup(args.fpl_team_id)
set_lineup(args.fpl_team_id, skip_check=confirm)
except Exception as e:
raise Exception(
"Something went wrong when making transfers. Check your team and make "
Expand Down
9 changes: 6 additions & 3 deletions airsenal/scripts/set_lineup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def make_squad_transfers(squad: Squad, priced_transfers: List[dict]) -> None:


def set_lineup(
fpl_team_id: Optional[int] = None, verbose: Optional[bool] = False
fpl_team_id: Optional[int] = None,
verbose: Optional[bool] = False,
skip_check: bool = False,
) -> None:
"""
Retrieve the latest lineup and apply the latest prediction to it.
Expand All @@ -104,17 +106,18 @@ def set_lineup(

squad.optimize_lineup(NEXT_GAMEWEEK, get_latest_prediction_tag())

if check_proceed(squad):
if check_proceed(squad) and not skip_check:
payload = build_lineup_payload(squad)
fetcher.post_lineup(payload)


def main():
parser = argparse.ArgumentParser("Set the starting 11 and captain")
parser.add_argument("--fpl_team_id", help="ID of the squad in FPL API", type=int)
parser.add_argument("--confirm", help="skip confirmation step", action="store_true")
args = parser.parse_args()
try:
set_lineup(args.fpl_team_id)
set_lineup(args.fpl_team_id, skip_check=args.confirm)
except Exception as e:
raise Exception(
"Something went wrong when setting lineup. Check your lineup manually on "
Expand Down

0 comments on commit 986645d

Please sign in to comment.