Fix team_lineup crash when pitcher lacks pitcherscouting
Card 6605 (Ohtani) placed at position P had pitcherscouting_id=NULL,
causing AttributeError when accessing pitcherscouting.pitchingcard.hand.
Added null check with fallback to batterscouting hand or '?' if neither
scouting record exists.
Also fixed set notation bug on line 240 where {value} created a Python
set instead of a string.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
541c5bbc1e
commit
329658ce8d
@ -237,12 +237,18 @@ class Game(SQLModel, table=True):
|
|||||||
for line in all_lineups:
|
for line in all_lineups:
|
||||||
logger.info(f'line in all_lineups: {line}')
|
logger.info(f'line in all_lineups: {line}')
|
||||||
if with_links:
|
if with_links:
|
||||||
name_string = {line.player.name_card_link("batting" if line.position != "P" else "pitching")}
|
name_string = line.player.name_card_link("batting" if line.position != "P" else "pitching")
|
||||||
else:
|
else:
|
||||||
name_string = f'{line.player.name_with_desc}'
|
name_string = f'{line.player.name_with_desc}'
|
||||||
|
|
||||||
if line.position == 'P':
|
if line.position == 'P':
|
||||||
this_hand = line.card.pitcherscouting.pitchingcard.hand
|
if line.card.pitcherscouting:
|
||||||
|
this_hand = line.card.pitcherscouting.pitchingcard.hand
|
||||||
|
elif line.card.batterscouting:
|
||||||
|
# Fallback to batting hand if pitcherscouting is missing
|
||||||
|
this_hand = line.card.batterscouting.battingcard.hand
|
||||||
|
else:
|
||||||
|
this_hand = '?'
|
||||||
else:
|
else:
|
||||||
this_hand = line.card.batterscouting.battingcard.hand
|
this_hand = line.card.batterscouting.battingcard.hand
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user