fix: remove empty if-pass stubs after db_post calls in complete_game (#38)
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m22s
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m22s
Removed two dead `if len(resp) > 0: pass` blocks after posting plays and decisions to the API. These stubs had no effect and only created confusion. Also removed the `resp =` assignments since the return values were never used. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4781ec11db
commit
41c33e6d42
@ -75,7 +75,6 @@ from utilities.dropdown import (
|
|||||||
from utilities.embeds import image_embed
|
from utilities.embeds import image_embed
|
||||||
from utilities.pages import Pagination
|
from utilities.pages import Pagination
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("discord_app")
|
logger = logging.getLogger("discord_app")
|
||||||
WPA_DF = pd.read_csv(f"storage/wpa_data.csv").set_index("index")
|
WPA_DF = pd.read_csv(f"storage/wpa_data.csv").set_index("index")
|
||||||
TO_BASE = {2: "to second", 3: "to third", 4: "home"}
|
TO_BASE = {2: "to second", 3: "to third", 4: "home"}
|
||||||
@ -612,9 +611,11 @@ async def read_lineup(
|
|||||||
this_game,
|
this_game,
|
||||||
this_team=lineup_team,
|
this_team=lineup_team,
|
||||||
lineup_num=lineup_num,
|
lineup_num=lineup_num,
|
||||||
roster_num=this_game.away_roster_id
|
roster_num=(
|
||||||
if this_game.home_team.is_ai
|
this_game.away_roster_id
|
||||||
else this_game.home_roster_id,
|
if this_game.home_team.is_ai
|
||||||
|
else this_game.home_roster_id
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
@ -759,7 +760,11 @@ def complete_play(session: Session, this_play: Play):
|
|||||||
opponent_play = get_last_team_play(
|
opponent_play = get_last_team_play(
|
||||||
session, this_play.game, this_play.pitcher.team
|
session, this_play.game, this_play.pitcher.team
|
||||||
)
|
)
|
||||||
nbo = opponent_play.batting_order + 1 if opponent_play.pa == 1 else opponent_play.batting_order
|
nbo = (
|
||||||
|
opponent_play.batting_order + 1
|
||||||
|
if opponent_play.pa == 1
|
||||||
|
else opponent_play.batting_order
|
||||||
|
)
|
||||||
except PlayNotFoundException as e:
|
except PlayNotFoundException as e:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"logic_gameplay - complete_play - No last play found for {this_play.pitcher.team.sname}, setting upcoming batting order to 1"
|
f"logic_gameplay - complete_play - No last play found for {this_play.pitcher.team.sname}, setting upcoming batting order to 1"
|
||||||
@ -1106,7 +1111,8 @@ async def get_lineups_from_sheets(
|
|||||||
position = row[0].upper()
|
position = row[0].upper()
|
||||||
if position != "DH":
|
if position != "DH":
|
||||||
player_positions = [
|
player_positions = [
|
||||||
getattr(this_card.player, f"pos_{i}") for i in range(1, 9)
|
getattr(this_card.player, f"pos_{i}")
|
||||||
|
for i in range(1, 9)
|
||||||
if getattr(this_card.player, f"pos_{i}") is not None
|
if getattr(this_card.player, f"pos_{i}") is not None
|
||||||
]
|
]
|
||||||
if position not in player_positions:
|
if position not in player_positions:
|
||||||
@ -1216,7 +1222,10 @@ async def get_full_roster_from_sheets(
|
|||||||
|
|
||||||
|
|
||||||
async def checks_log_interaction(
|
async def checks_log_interaction(
|
||||||
session: Session, interaction: discord.Interaction, command_name: str, lock_play: bool = True
|
session: Session,
|
||||||
|
interaction: discord.Interaction,
|
||||||
|
command_name: str,
|
||||||
|
lock_play: bool = True,
|
||||||
) -> tuple[Game, Team, Play]:
|
) -> tuple[Game, Team, Play]:
|
||||||
"""
|
"""
|
||||||
Validates interaction permissions and optionally locks the current play for processing.
|
Validates interaction permissions and optionally locks the current play for processing.
|
||||||
@ -3862,7 +3871,14 @@ async def xchecks(
|
|||||||
this_play.run,
|
this_play.run,
|
||||||
this_play.triple,
|
this_play.triple,
|
||||||
this_play.batter_final,
|
this_play.batter_final,
|
||||||
) = 1, 1, 1, 1, 1, 4
|
) = (
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
)
|
||||||
this_play = advance_runners(session, this_play, num_bases=4, earned_bases=3)
|
this_play = advance_runners(session, this_play, num_bases=4, earned_bases=3)
|
||||||
|
|
||||||
session.add(this_play)
|
session.add(this_play)
|
||||||
@ -4291,23 +4307,17 @@ async def complete_game(
|
|||||||
|
|
||||||
# Post game stats to API
|
# Post game stats to API
|
||||||
try:
|
try:
|
||||||
resp = await db_post("plays", payload=db_ready_plays)
|
await db_post("plays", payload=db_ready_plays)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await roll_back(db_game["id"], plays=True)
|
await roll_back(db_game["id"], plays=True)
|
||||||
log_exception(e, msg="Unable to post plays to API, rolling back")
|
log_exception(e, msg="Unable to post plays to API, rolling back")
|
||||||
|
|
||||||
if len(resp) > 0:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = await db_post("decisions", payload={"decisions": db_ready_decisions})
|
await db_post("decisions", payload={"decisions": db_ready_decisions})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await roll_back(db_game["id"], plays=True, decisions=True)
|
await roll_back(db_game["id"], plays=True, decisions=True)
|
||||||
log_exception(e, msg="Unable to post decisions to API, rolling back")
|
log_exception(e, msg="Unable to post decisions to API, rolling back")
|
||||||
|
|
||||||
if len(resp) > 0:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Post game rewards (gauntlet and main team)
|
# Post game rewards (gauntlet and main team)
|
||||||
try:
|
try:
|
||||||
win_reward, loss_reward = await post_game_rewards(
|
win_reward, loss_reward = await post_game_rewards(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user