Scorecard submission bug fixes
This commit is contained in:
parent
2a2b830169
commit
93688ca33c
@ -1093,16 +1093,42 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
logging.info(f'gdata: {g_data}\nweek/game: {week_num}/{game_num}')
|
logging.info(f'gdata: {g_data}\nweek/game: {week_num}/{game_num}')
|
||||||
|
|
||||||
|
# Confirm submitting GM
|
||||||
|
if await get_team_by_owner(current['season'], interaction.user.id) not in [home_team, away_team] and \
|
||||||
|
interaction.user.id != self.bot.owner_id:
|
||||||
|
await interaction.edit_original_response(
|
||||||
|
content=f'{await get_emoji(interaction, "squint")} Only a GM of the two teams can submit scorecards.'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
# Confirm teams and matchup
|
# Confirm teams and matchup
|
||||||
dupe_g_query = await db_get('games', params=[
|
dupe_g_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week', week_num), ('game_num', game_num),
|
('season', current['season']), ('week', week_num), ('game_num', game_num),
|
||||||
('away_team_id', away_team['id']), ('home_team_id', home_team['id'])
|
('away_team_id', away_team['id']), ('home_team_id', home_team['id'])
|
||||||
])
|
])
|
||||||
if dupe_g_query['count'] != 0:
|
if dupe_g_query['count'] != 0:
|
||||||
|
dupe_game = dupe_g_query['games'][0]
|
||||||
|
view = Confirm(responders=[interaction.user], timeout=30)
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content=f'This game has already been played! Maybe one day I can automatically wipe it for you.'
|
content=f'This game has already been played! Would you like me to wipe the old one and re-submit?',
|
||||||
|
view=view
|
||||||
)
|
)
|
||||||
return
|
await view.wait()
|
||||||
|
|
||||||
|
if view.value:
|
||||||
|
await interaction.edit_original_response(
|
||||||
|
content='Okay, let me wipe the old shit...',
|
||||||
|
view=None
|
||||||
|
)
|
||||||
|
await db_delete('plays/game', object_id=dupe_game['id'])
|
||||||
|
await db_delete('decisions/game', object_id=dupe_game['id'])
|
||||||
|
await db_post(f'games/wipe/{dupe_game["id"]}')
|
||||||
|
else:
|
||||||
|
await interaction.edit_original_response(
|
||||||
|
content='You think on it some more and get back to me later.',
|
||||||
|
view=None
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
g_query = await db_get('games', params=[
|
g_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week', week_num), ('away_team_id', away_team['id']),
|
('season', current['season']), ('week', week_num), ('away_team_id', away_team['id']),
|
||||||
@ -1117,14 +1143,6 @@ class Players(commands.Cog):
|
|||||||
this_game = g_query['games'][0]
|
this_game = g_query['games'][0]
|
||||||
logging.info(f'this_game: {this_game}')
|
logging.info(f'this_game: {this_game}')
|
||||||
|
|
||||||
# Confirm submitting GM
|
|
||||||
if await get_team_by_owner(current['season'], interaction.user.id) not in [home_team, away_team] and \
|
|
||||||
interaction.user.id != self.bot.owner_id:
|
|
||||||
await interaction.edit_original_response(
|
|
||||||
content=f'{await get_emoji(interaction, "squint")} Only a GM of the two teams can submit scorecards.'
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
# TODO: check for stats and wipe
|
# TODO: check for stats and wipe
|
||||||
logging.info(f'checking for old stats')
|
logging.info(f'checking for old stats')
|
||||||
|
|
||||||
@ -1195,6 +1213,7 @@ class Players(commands.Cog):
|
|||||||
# return
|
# return
|
||||||
|
|
||||||
# Read scorecard
|
# Read scorecard
|
||||||
|
await interaction.edit_original_response(content='Here I go sheetsing again...', view=None)
|
||||||
logging.info(f'sba-submit - reading scorecard')
|
logging.info(f'sba-submit - reading scorecard')
|
||||||
playtable = scorecard.worksheet_by_title('Playtable')
|
playtable = scorecard.worksheet_by_title('Playtable')
|
||||||
all_plays = playtable.get_values('B3', 'BG300')
|
all_plays = playtable.get_values('B3', 'BG300')
|
||||||
@ -1202,12 +1221,12 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
play_keys = [
|
play_keys = [
|
||||||
'play_num', 'batter_id', 'batter_pos', 'pitcher_id', 'on_base_code', 'inning_half', 'inning_num',
|
'play_num', 'batter_id', 'batter_pos', 'pitcher_id', 'on_base_code', 'inning_half', 'inning_num',
|
||||||
'batting_order', 'starting_outs', 'away_score', 'home_score', 'on_first', 'on_first_final', 'on_second',
|
'batting_order', 'starting_outs', 'away_score', 'home_score', 'on_first_id', 'on_first_final',
|
||||||
'on_second_final', 'on_third', 'on_third_final', 'batter_final', 'pa', 'ab', 'run', 'pitcher_earned_run',
|
'on_second_id', 'on_second_final', 'on_third_id', 'on_third_final', 'batter_final', 'pa', 'ab', 'run',
|
||||||
'hit', 'rbi', 'double', 'triple', 'homerun', 'bb', 'so', 'hbp', 'sac', 'ibb', 'gidp', 'bphr', 'bpfo',
|
'pitcher_earned_run', 'hit', 'rbi', 'double', 'triple', 'homerun', 'bb', 'so', 'hbp', 'sac', 'ibb', 'gidp',
|
||||||
'bp1b', 'bplo', 'sb', 'cs', 'outs', 'pitcher_rest_outs', 'wpa', 'catcher_id', 'defender_id', 'runner_id',
|
'bphr', 'bpfo', 'bp1b', 'bplo', 'sb', 'cs', 'outs', 'pitcher_rest_outs', 'wpa', 'catcher_id', 'defender_id',
|
||||||
'check_pos', 'error', 'wild_pitch', 'passed_ball', 'pick_off', 'balk', 'is_go_ahead', 'is_tied',
|
'runner_id', 'check_pos', 'error', 'wild_pitch', 'passed_ball', 'pick_off', 'balk', 'is_go_ahead',
|
||||||
'is_new_inning', 'inherited_runners', 'inherited_scored', 'on_hook_for_loss', 'run_differential'
|
'is_tied', 'is_new_inning', 'inherited_runners', 'inherited_scored', 'on_hook_for_loss', 'run_differential'
|
||||||
]
|
]
|
||||||
p_data = []
|
p_data = []
|
||||||
for line in all_plays:
|
for line in all_plays:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user