Implement !standings for s8

This commit is contained in:
Cal Corum 2023-08-05 00:27:31 -05:00
parent 72d7180942
commit bb6cc8ee84
2 changed files with 30 additions and 28 deletions

View File

@ -242,18 +242,20 @@ class Players(commands.Cog):
@staticmethod @staticmethod
async def game_progress(current): async def game_progress(current):
s_query = await db_get('schedules', params=[ # s_query = await db_get('schedules', params=[
('season', current['season']), ('week_start', current['week']), ('week_end', current['week']) # ('season', current['season']), ('week_start', current['week']), ('week_end', current['week'])
# ])
# r_query = await db_get('results', params=[
# ('season', current['season']), ('week_start', current['week']), ('week_end', current['week'])
# ])
gp_query = await db_get('games', params=[
('season', current['season']), ('week', current['week']), ('played', True)
]) ])
r_query = await db_get('results', params=[ all_query = await db_get('games', params=[
('season', current['season']), ('week_start', current['week']), ('week_end', current['week']) ('season', current['season']), ('week', current['week'])
]) ])
game_count = 0 return {'games_played': gp_query['count'], 'game_count': all_query['count']}
for x in s_query['schedules']:
game_count += x['gamecount']
return {'games_played': r_query['count'], 'game_count': game_count}
@commands.Cog.listener(name='on_message') @commands.Cog.listener(name='on_message')
async def on_message_listener(self, message): async def on_message_listener(self, message):
@ -748,19 +750,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']), ('league_abbrev', 'al'), ('division_abbrev', 'e') ('season', current['season']), ('division_abbrev', 'FD')
]) ])
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']), ('league_abbrev', 'al'), ('division_abbrev', 'w') ('season', current['season']), ('division_abbrev', 'NLW')
]) ])
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']), ('league_abbrev', 'nl'), ('division_abbrev', 'e') ('season', current['season']), ('division_abbrev', 'IWGP')
]) ])
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']), ('league_abbrev', 'nl'), ('division_abbrev', 'w') ('season', current['season']), ('division_abbrev', 'BAL')
]) ])
div_four = d4_query['standings'] div_four = d4_query['standings']
@ -790,32 +792,32 @@ 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'**AL East**', value=div_one_standings, inline=False) embed.add_field(name=f'**Fun Diff**', value=div_one_standings, inline=False)
embed.add_field(name=f'**AL West**', value=div_two_standings, inline=False) embed.add_field(name=f'**NL West**', value=div_two_standings, inline=False)
embed.add_field(name=f'**NL East**', value=div_three_standings, inline=False) embed.add_field(name=f'**IWGP**', value=div_three_standings, inline=False)
embed.add_field(name=f'**NL West**', value=div_four_standings, inline=False) embed.add_field(name=f'**Crabbers**', value=div_four_standings, inline=False)
return embed return embed
async def get_wildcard_standings(self, current) -> discord.Embed: async def get_wildcard_standings(self, current) -> discord.Embed:
a_query = await db_get('standings', params=[ a_query = await db_get('standings', params=[
('season', current['season']), ('league_abbrev', 'al') ('season', current['season']), ('league_abbrev', 'SBa')
]) ])
al_teams = a_query['standings'] al_teams = a_query['standings']
n_query = await db_get('standings', params=[ # n_query = await db_get('standings', params=[
('season', current['season']), ('league_abbrev', 'nl') # ('season', current['season']), ('league_abbrev', 'nl')
]) # ])
nl_teams = n_query['standings'] # nl_teams = n_query['standings']
al_wildcard = f'```\nTeam W-L PCT GB E# RD\n' al_wildcard = f'```\nTeam W-L PCT GB E# RD\n'
for team in al_teams: for team in al_teams:
al_wildcard += self.team_stan_line(team, s_type='wc') al_wildcard += self.team_stan_line(team, s_type='wc')
al_wildcard += '```' al_wildcard += '```'
nl_wildcard = f'```\nTeam W-L PCT GB E# RD\n' # nl_wildcard = f'```\nTeam W-L PCT GB E# RD\n'
for team in nl_teams: # for team in nl_teams:
nl_wildcard += self.team_stan_line(team, s_type='wc') # nl_wildcard += self.team_stan_line(team, s_type='wc')
nl_wildcard += '```' # nl_wildcard += '```'
progress = await self.game_progress(current) progress = await self.game_progress(current)
@ -824,7 +826,7 @@ class Players(commands.Cog):
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'**AL Wildcard**', value=al_wildcard, inline=False) embed.add_field(name=f'**AL Wildcard**', value=al_wildcard, inline=False)
embed.add_field(name=f'**NL Wildcard**', value=nl_wildcard, inline=False) # embed.add_field(name=f'**NL Wildcard**', value=nl_wildcard, inline=False)
return embed return embed

View File

@ -470,7 +470,7 @@ class Transactions(commands.Cog):
new_team = move['newteam'] new_team = move['newteam']
# team_record = await get_team_record(new_team, week_num=current["week"]) # team_record = await get_team_record(new_team, week_num=current["week"])
r_query = await db_get('standings', params=[ r_query = await db_get('standings', params=[
('season', current['season']), ('team_abbrev', new_team['abbrev']) ('season', current['season']), ('team_id', new_team['id'])
]) ])
win_pct = r_query['standings'][0]['wins'] / ( win_pct = r_query['standings'][0]['wins'] / (
r_query['standings'][0]['wins'] + r_query['standings'][0]['losses']) r_query['standings'][0]['wins'] + r_query['standings'][0]['losses'])