Post Draft fixes for season 12
This commit is contained in:
parent
b4d84b6125
commit
9bb84ce287
2
.gitignore
vendored
2
.gitignore
vendored
@ -60,3 +60,5 @@ card-creation/
|
|||||||
.dockerignore
|
.dockerignore
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
venv/
|
venv/
|
||||||
|
CLAUDE.md
|
||||||
|
/.claude**
|
||||||
|
|||||||
@ -35,3 +35,11 @@ class Player(pydantic.BaseModel):
|
|||||||
bbref_id: Optional[str] = None
|
bbref_id: Optional[str] = None
|
||||||
injury_rating: Optional[str] = None
|
injury_rating: Optional[str] = None
|
||||||
sbaplayer_id: Optional[int] = None
|
sbaplayer_id: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
|
async def get_one_player(player_id: int) -> Player:
|
||||||
|
data = await db_get('players', object_id=player_id)
|
||||||
|
if not data:
|
||||||
|
log_exception(ApiException(f'No player found with ID {player_id}'))
|
||||||
|
|
||||||
|
return Player(**data)
|
||||||
|
|||||||
@ -9,7 +9,7 @@ from api_calls.draft_pick import DraftPick, get_one_draftpick, patch_draftpick
|
|||||||
from api_calls.player import Player
|
from api_calls.player import Player
|
||||||
from exceptions import ApiException, log_exception
|
from exceptions import ApiException, log_exception
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from db_calls import db_get, db_patch, put_player, db_post, get_player_by_name
|
from db_calls import db_delete, db_get, db_patch, put_player, db_post, get_player_by_name
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
|
|
||||||
from discord import TextChannel, app_commands
|
from discord import TextChannel, app_commands
|
||||||
@ -449,6 +449,7 @@ class Draft(commands.Cog):
|
|||||||
f'{draft_pick.owner.lname} selects {player["name"]} with the #{draft_pick.overall} overall pick'
|
f'{draft_pick.owner.lname} selects {player["name"]} with the #{draft_pick.overall} overall pick'
|
||||||
)
|
)
|
||||||
draft_pick.player = Player(**player)
|
draft_pick.player = Player(**player)
|
||||||
|
logger.info(f'draft_pick test: {draft_pick}')
|
||||||
await patch_draftpick(draft_pick) # TODO: uncomment for live draft
|
await patch_draftpick(draft_pick) # TODO: uncomment for live draft
|
||||||
|
|
||||||
player['team']['id'] = draft_pick.owner.id
|
player['team']['id'] = draft_pick.owner.id
|
||||||
@ -781,12 +782,33 @@ class Draft(commands.Cog):
|
|||||||
temp_player['team'] = fa_team
|
temp_player['team'] = fa_team
|
||||||
this_player = await put_player(temp_player)
|
this_player = await put_player(temp_player)
|
||||||
|
|
||||||
# this_player = await get_player_by_name(current.season, this_pick['player']['id'])
|
t_query = await db_get(
|
||||||
# this_player = await db_get('players', object_id=this_pick['player']['id'])
|
'transactions',
|
||||||
|
params=[('season', 12), ('move_id', f'draft-overall-{this_pick.overall}')]
|
||||||
|
)
|
||||||
|
if not t_query or t_query.get('count', 0) == 0:
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content='Don\'t forget to delete the transaction from the database.',
|
content='I couldn\'t find the transaction record of this move so that\'s Cal\'s problem now. The pick is wiped, though.',
|
||||||
embed=await get_player_embed(this_player, current)
|
embed=await get_player_embed(this_player, current)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
del_query = await db_delete(
|
||||||
|
'transactions',
|
||||||
|
object_id=t_query['transactions'][0]['moveid']
|
||||||
|
)
|
||||||
|
except ValueError as e:
|
||||||
|
logger.error(f'Could not delete draft transaction: {e}')
|
||||||
|
await interaction.edit_original_response(
|
||||||
|
content='I couldn\'t delete the transaction record of this move so that\'s Cal\'s problem now. The pick is wiped, though.',
|
||||||
|
embed=await get_player_embed(this_player, current)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
await interaction.edit_original_response(
|
||||||
|
content=f'[I gotchu]({random_gif("blows kiss")}) boo boo, like it never even happened.',
|
||||||
|
embed=await get_player_embed(this_player, current)
|
||||||
|
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if pick_lock is not None:
|
if pick_lock is not None:
|
||||||
|
|||||||
@ -800,7 +800,7 @@ class Gameday(commands.Cog):
|
|||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME)
|
||||||
async def new_game_command(self, ctx):
|
async def new_game_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await db_get('current')
|
||||||
this_team = await get_team_by_owner(current['season'], ctx.author.id)
|
this_team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
|
|
||||||
await ctx.send('**Note:** Make sure this is the channel where you will be playing commands. Once this is set, '
|
await ctx.send('**Note:** Make sure this is the channel where you will be playing commands. Once this is set, '
|
||||||
'I will only take gameplay commands here.')
|
'I will only take gameplay commands here.')
|
||||||
@ -828,9 +828,9 @@ class Gameday(commands.Cog):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
this_matchup = await get_one_schedule(
|
this_matchup = await get_one_schedule(
|
||||||
season=current['season'],
|
season=current.season,
|
||||||
team_abbrev1=this_team['abbrev'],
|
team_abbrev1=this_team['abbrev'],
|
||||||
week=current['week']
|
week=current.week
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
home_team = await get_team('home')
|
home_team = await get_team('home')
|
||||||
|
|||||||
@ -1191,19 +1191,19 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
async def get_division_standings(self, current) -> discord.Embed:
|
async def get_division_standings(self, current) -> discord.Embed:
|
||||||
d1_query = await db_get('standings', params=[
|
d1_query = await db_get('standings', params=[
|
||||||
('season', current.season), ('division_abbrev', 'SD')
|
('season', current.season), ('division_abbrev', 'TC')
|
||||||
])
|
])
|
||||||
div_one = d1_query['standings']
|
div_one = d1_query['standings']
|
||||||
d2_query = await db_get('standings', params=[
|
d2_query = await db_get('standings', params=[
|
||||||
('season', current.season), ('division_abbrev', 'DC')
|
('season', current.season), ('division_abbrev', 'ETSOS')
|
||||||
])
|
])
|
||||||
div_two = d2_query['standings']
|
div_two = d2_query['standings']
|
||||||
d3_query = await db_get('standings', params=[
|
d3_query = await db_get('standings', params=[
|
||||||
('season', current.season), ('division_abbrev', 'FIP')
|
('season', current.season), ('division_abbrev', 'APL')
|
||||||
])
|
])
|
||||||
div_three = d3_query['standings']
|
div_three = d3_query['standings']
|
||||||
d4_query = await db_get('standings', params=[
|
d4_query = await db_get('standings', params=[
|
||||||
('season', current.season), ('division_abbrev', 'DOC')
|
('season', current.season), ('division_abbrev', 'BBC')
|
||||||
])
|
])
|
||||||
div_four = d4_query['standings']
|
div_four = d4_query['standings']
|
||||||
|
|
||||||
@ -1233,10 +1233,10 @@ class Players(commands.Cog):
|
|||||||
f'{progress["games_played"]}/{progress["game_count"]} games played',
|
f'{progress["games_played"]}/{progress["game_count"]} games played',
|
||||||
color=0xB70000)
|
color=0xB70000)
|
||||||
embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
||||||
embed.add_field(name=f'**Snow Day**', value=div_one_standings, inline=False)
|
embed.add_field(name=f'**Traveling Circus**', value=div_one_standings, inline=False)
|
||||||
embed.add_field(name=f'**Dinger Central**', value=div_two_standings, inline=False)
|
embed.add_field(name=f'**ETSOS**', value=div_two_standings, inline=False)
|
||||||
embed.add_field(name=f'**Just the FIP**', value=div_three_standings, inline=False)
|
embed.add_field(name=f'**Apple**', value=div_three_standings, inline=False)
|
||||||
embed.add_field(name=f'**Division of Cook**', value=div_four_standings, inline=False)
|
embed.add_field(name=f'**Big Chungus**', value=div_four_standings, inline=False)
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@ -1520,7 +1520,7 @@ class Players(commands.Cog):
|
|||||||
setup_tab = scorecard.worksheet_by_title('Setup')
|
setup_tab = scorecard.worksheet_by_title('Setup')
|
||||||
|
|
||||||
scorecard_version = setup_tab.get_value('V35')
|
scorecard_version = setup_tab.get_value('V35')
|
||||||
if int(scorecard_version) != current.bet_week:
|
if scorecard_version != current.bet_week:
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content=f'It looks like this scorecard is out of date. Did you create a new card at the start of the '
|
content=f'It looks like this scorecard is out of date. Did you create a new card at the start of the '
|
||||||
f'game? If you did, let Cal know about this error. If not, I\'ll need you to use an up to '
|
f'game? If you did, let Cal know about this error. If not, I\'ll need you to use an up to '
|
||||||
|
|||||||
@ -5,7 +5,7 @@ from helpers import *
|
|||||||
from api_calls.current import get_current
|
from api_calls.current import get_current
|
||||||
from db_calls import db_get, db_patch, get_team_by_owner, get_team_by_abbrev, get_player_by_name, put_player, db_post
|
from db_calls import db_get, db_patch, get_team_by_owner, get_team_by_abbrev, get_player_by_name, put_player, db_post
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
OFFSEASON_FLAG = True
|
OFFSEASON_FLAG = False
|
||||||
logger = logging.getLogger('discord_app')
|
logger = logging.getLogger('discord_app')
|
||||||
|
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ class Transactions(commands.Cog):
|
|||||||
# if now.weekday() == 0 and now.hour == 5 and not current.freeze: # Spring/Summer
|
# if now.weekday() == 0 and now.hour == 5 and not current.freeze: # Spring/Summer
|
||||||
if now.weekday() == 0 and now.hour == 0 and not current.freeze: # Fall/Winter
|
if now.weekday() == 0 and now.hour == 0 and not current.freeze: # Fall/Winter
|
||||||
current.week += 1
|
current.week += 1
|
||||||
await db_patch('current', object_id=current['id'], params=[('week', current.week), ('freeze', True)])
|
await db_patch('current', object_id=current.id, params=[('week', current.week), ('freeze', True)])
|
||||||
await self.run_transactions(current)
|
await self.run_transactions(current)
|
||||||
|
|
||||||
logger.debug(f'Building freeze string')
|
logger.debug(f'Building freeze string')
|
||||||
@ -372,7 +372,7 @@ class Transactions(commands.Cog):
|
|||||||
# End Freeze
|
# End Freeze
|
||||||
# elif now.weekday() == 5 and now.hour == 5 and current.freeze: # Spring/Summer
|
# elif now.weekday() == 5 and now.hour == 5 and current.freeze: # Spring/Summer
|
||||||
elif now.weekday() == 5 and now.hour == 0 and current.freeze: # Fall/Winter
|
elif now.weekday() == 5 and now.hour == 0 and current.freeze: # Fall/Winter
|
||||||
await db_patch('current', object_id=current['id'], params=[('freeze', False)])
|
await db_patch('current', object_id=current.id, params=[('freeze', False)])
|
||||||
|
|
||||||
week_num = f'Week {current.week}'
|
week_num = f'Week {current.week}'
|
||||||
stars = f'{"":*<30}'
|
stars = f'{"":*<30}'
|
||||||
@ -643,7 +643,7 @@ class Transactions(commands.Cog):
|
|||||||
await ctx.send(f'The trade deadline is **week {current.trade_deadline}**. Since it is currently **week '
|
await ctx.send(f'The trade deadline is **week {current.trade_deadline}**. Since it is currently **week '
|
||||||
f'{current.week}** I am just going to stop you right there.')
|
f'{current.week}** I am just going to stop you right there.')
|
||||||
return
|
return
|
||||||
if current.week < -2:
|
if current.week < -2 or current.week == -1:
|
||||||
await ctx.send(await get_emoji(ctx, 'oof', False))
|
await ctx.send(await get_emoji(ctx, 'oof', False))
|
||||||
await ctx.send(f'Patience, grasshopper. Trades open soon.')
|
await ctx.send(f'Patience, grasshopper. Trades open soon.')
|
||||||
return
|
return
|
||||||
|
|||||||
@ -160,6 +160,12 @@ async def db_delete(endpoint: str, object_id: int, api_ver: int = 3, timeout=3):
|
|||||||
raise ValueError(f'DB: {e}')
|
raise ValueError(f'DB: {e}')
|
||||||
|
|
||||||
|
|
||||||
|
# async def db_delete_transaction(move_id: str):
|
||||||
|
# req_url = get_req_url('transactions', api_ver=3, object_id=move_id)
|
||||||
|
# log_string = f'delete:\n{endpoint} {object_id}'
|
||||||
|
# logger.info(log_string) if master_debug else logger.debug(log_string)
|
||||||
|
|
||||||
|
|
||||||
async def get_team_by_abbrev(team_abbrev: str, season: int):
|
async def get_team_by_abbrev(team_abbrev: str, season: int):
|
||||||
t_query = await db_get('teams', params=[('season', season), ('team_abbrev', team_abbrev)])
|
t_query = await db_get('teams', params=[('season', season), ('team_abbrev', team_abbrev)])
|
||||||
if not t_query or t_query['count'] == 0:
|
if not t_query or t_query['count'] == 0:
|
||||||
|
|||||||
@ -37,7 +37,8 @@ SBA_SEASON7_DRAFT_KEY = '1BgySsUlQf9K21_uOjQOY7O0GrRfF6zt1BBaEFlvBokY'
|
|||||||
SBA_SEASON8_DRAFT_KEY = '1FG4cAs8OeTdrreRqu8D-APxibjB3RiEzn34KTTBLLDk'
|
SBA_SEASON8_DRAFT_KEY = '1FG4cAs8OeTdrreRqu8D-APxibjB3RiEzn34KTTBLLDk'
|
||||||
SBA_SEASON9_DRAFT_KEY = '1eyHqaVU9rtmhG1p0ZktOrz7FMDp3c_unCcFyMMYceLc'
|
SBA_SEASON9_DRAFT_KEY = '1eyHqaVU9rtmhG1p0ZktOrz7FMDp3c_unCcFyMMYceLc'
|
||||||
DRAFT_KEY = {
|
DRAFT_KEY = {
|
||||||
11: '1Fz3GcTb7b9tLe8vkpyn59wRwC6P2QzxnLKtp7371sUc'
|
11: '1Fz3GcTb7b9tLe8vkpyn59wRwC6P2QzxnLKtp7371sUc',
|
||||||
|
12: '1OF-sAFykebc_2BrcYCgxCR-4rJo0GaNmTstagV-PMBU'
|
||||||
}
|
}
|
||||||
SBA_STANDINGS_URL = f'{SBA_BASE_URL}/standings'
|
SBA_STANDINGS_URL = f'{SBA_BASE_URL}/standings'
|
||||||
SBA_SCHEDULE_URL = f'{SBA_BASE_URL}/schedule'
|
SBA_SCHEDULE_URL = f'{SBA_BASE_URL}/schedule'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user