From 3eaf0bac70f2f56b6284c1a9aef1adcd58abd401 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 9 Jun 2023 12:36:30 -0500 Subject: [PATCH] Fixed patch current bug --- cogs/admins.py | 18 ++++++++++-------- db_calls.py | 8 ++++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cogs/admins.py b/cogs/admins.py index c46a478..865193c 100644 --- a/cogs/admins.py +++ b/cogs/admins.py @@ -74,15 +74,17 @@ class Admins(commands.Cog): @commands.command(name='test', hidden=True) @commands.is_owner() async def test_command(self, ctx): - current = await get_current() - week_num = f'Week {current["week"]}' - stars = f'{"":*<32}' - freeze_message = f'```\n' \ - f'{stars}\n'\ - f'{week_num: >9} Freeze Period Begins\n' \ - f'{stars}\n```' + # week_num = f'Week {current["week"]}' + # stars = f'{"":*<32}' + # freeze_message = f'```\n' \ + # f'{stars}\n'\ + # f'{week_num: >9} Freeze Period Begins\n' \ + # f'{stars}\n```' + # + # await send_to_channel(self.bot, 'general', freeze_message) - await send_to_channel(self.bot, 'general', freeze_message) + current = await patch_current(freeze=False) + await ctx.send(f'Current: {current}') @commands.command(name='sendmoves', help='Send moves to sheets') @commands.is_owner() diff --git a/db_calls.py b/db_calls.py index f30f844..fbb7d1b 100644 --- a/db_calls.py +++ b/db_calls.py @@ -178,7 +178,6 @@ async def get_current(season=None): async def patch_current( week=None, freeze=None, season=None, transcount=None, bstatcount=None, pstatcount=None, bet_week=None, trade_deadline=None, pick_trade_start=None, pick_trade_end=None, injury_count=None): - current = await db_get('current') params = [] if week is not None: params.append(('week', week)) @@ -203,7 +202,12 @@ async def patch_current( if injury_count is not None: params.append(('injury_count', injury_count)) - return await db_patch('current', object_id=current['id'], params=params) + resp = requests.patch(get_req_url('current', params=params), data=None, headers=AUTH_TOKEN, timeout=3) + if resp.status_code == 200: + return True + else: + logging.warning(resp.text) + raise ValueError(f'DB: {resp.text}') async def get_one_team(id_or_abbrev, season=None, is_pd=False, timeout=3):